ripper_ruby_parser 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +4 -23
  4. data/Rakefile +12 -12
  5. data/lib/ripper_ruby_parser.rb +2 -2
  6. data/lib/ripper_ruby_parser/commenting_ripper_parser.rb +9 -9
  7. data/lib/ripper_ruby_parser/parser.rb +3 -3
  8. data/lib/ripper_ruby_parser/sexp_handlers.rb +9 -9
  9. data/lib/ripper_ruby_parser/sexp_handlers/assignment.rb +3 -9
  10. data/lib/ripper_ruby_parser/sexp_handlers/blocks.rb +19 -24
  11. data/lib/ripper_ruby_parser/sexp_handlers/literals.rb +14 -18
  12. data/lib/ripper_ruby_parser/sexp_handlers/methods.rb +3 -3
  13. data/lib/ripper_ruby_parser/sexp_processor.rb +4 -4
  14. data/lib/ripper_ruby_parser/unescape.rb +11 -11
  15. data/lib/ripper_ruby_parser/version.rb +1 -1
  16. data/test/end_to_end/comments_test.rb +10 -10
  17. data/test/end_to_end/comparison_test.rb +28 -28
  18. data/test/end_to_end/lib_comparison_test.rb +6 -6
  19. data/test/end_to_end/line_numbering_test.rb +10 -10
  20. data/test/end_to_end/samples_comparison_test.rb +5 -5
  21. data/test/end_to_end/test_comparison_test.rb +6 -6
  22. data/test/pt_testcase/pt_test.rb +7 -7
  23. data/test/ripper_ruby_parser/commenting_ripper_parser_test.rb +163 -169
  24. data/test/ripper_ruby_parser/parser_test.rb +338 -338
  25. data/test/ripper_ruby_parser/sexp_handlers/assignment_test.rb +475 -511
  26. data/test/ripper_ruby_parser/sexp_handlers/blocks_test.rb +582 -564
  27. data/test/ripper_ruby_parser/sexp_handlers/conditionals_test.rb +469 -469
  28. data/test/ripper_ruby_parser/sexp_handlers/literals_test.rb +713 -724
  29. data/test/ripper_ruby_parser/sexp_handlers/loops_test.rb +155 -155
  30. data/test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb +181 -181
  31. data/test/ripper_ruby_parser/sexp_handlers/methods_test.rb +337 -352
  32. data/test/ripper_ruby_parser/sexp_handlers/operators_test.rb +298 -298
  33. data/test/ripper_ruby_parser/sexp_processor_test.rb +119 -119
  34. data/test/ripper_ruby_parser/version_test.rb +2 -2
  35. data/test/samples/lambdas.rb +5 -0
  36. data/test/samples/misc.rb +3 -0
  37. data/test/samples/strings.rb +7 -0
  38. data/test/test_helper.rb +8 -6
  39. metadata +12 -10
@@ -1,208 +1,208 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
3
+ require File.expand_path("../../test_helper.rb", File.dirname(__FILE__))
4
4
 
5
5
  describe RipperRubyParser::Parser do
6
- describe '#parse' do
7
- describe 'for the while statement' do
8
- it 'works with do' do
9
- 'while foo do; bar; end'.
10
- must_be_parsed_as s(:while,
11
- s(:call, nil, :foo),
12
- s(:call, nil, :bar), true)
6
+ describe "#parse" do
7
+ describe "for the while statement" do
8
+ it "works with do" do
9
+ _("while foo do; bar; end")
10
+ .must_be_parsed_as s(:while,
11
+ s(:call, nil, :foo),
12
+ s(:call, nil, :bar), true)
13
13
  end
14
14
 
15
- it 'works without do' do
16
- 'while foo; bar; end'.
17
- must_be_parsed_as s(:while,
18
- s(:call, nil, :foo),
19
- s(:call, nil, :bar), true)
15
+ it "works without do" do
16
+ _("while foo; bar; end")
17
+ .must_be_parsed_as s(:while,
18
+ s(:call, nil, :foo),
19
+ s(:call, nil, :bar), true)
20
20
  end
21
21
 
22
- it 'works in the single-line postfix case' do
23
- 'foo while bar'.
24
- must_be_parsed_as s(:while,
25
- s(:call, nil, :bar),
26
- s(:call, nil, :foo), true)
22
+ it "works in the single-line postfix case" do
23
+ _("foo while bar")
24
+ .must_be_parsed_as s(:while,
25
+ s(:call, nil, :bar),
26
+ s(:call, nil, :foo), true)
27
27
  end
28
28
 
29
- it 'works in the block postfix case' do
30
- 'begin; foo; end while bar'.
31
- must_be_parsed_as s(:while,
32
- s(:call, nil, :bar),
33
- s(:call, nil, :foo), false)
29
+ it "works in the block postfix case" do
30
+ _("begin; foo; end while bar")
31
+ .must_be_parsed_as s(:while,
32
+ s(:call, nil, :bar),
33
+ s(:call, nil, :foo), false)
34
34
  end
35
35
 
36
- it 'handles a negative condition' do
37
- 'while not foo; bar; end'.
38
- must_be_parsed_as s(:while,
39
- s(:call, s(:call, nil, :foo), :!),
40
- s(:call, nil, :bar), true)
36
+ it "handles a negative condition" do
37
+ _("while not foo; bar; end")
38
+ .must_be_parsed_as s(:while,
39
+ s(:call, s(:call, nil, :foo), :!),
40
+ s(:call, nil, :bar), true)
41
41
  end
42
42
 
43
- it 'handles a negative condition in the postfix case' do
44
- 'foo while not bar'.
45
- must_be_parsed_as s(:while,
46
- s(:call, s(:call, nil, :bar), :!),
47
- s(:call, nil, :foo), true)
43
+ it "handles a negative condition in the postfix case" do
44
+ _("foo while not bar")
45
+ .must_be_parsed_as s(:while,
46
+ s(:call, s(:call, nil, :bar), :!),
47
+ s(:call, nil, :foo), true)
48
48
  end
49
49
 
50
- it 'converts a negated match condition to :until' do
51
- 'while foo !~ bar; baz; end'.
52
- must_be_parsed_as s(:until,
53
- s(:call, s(:call, nil, :foo), :=~, s(:call, nil, :bar)),
54
- s(:call, nil, :baz), true)
50
+ it "converts a negated match condition to :until" do
51
+ _("while foo !~ bar; baz; end")
52
+ .must_be_parsed_as s(:until,
53
+ s(:call, s(:call, nil, :foo), :=~, s(:call, nil, :bar)),
54
+ s(:call, nil, :baz), true)
55
55
  end
56
56
 
57
- it 'converts a negated match condition to :until in the postfix case' do
58
- 'baz while foo !~ bar'.
59
- must_be_parsed_as s(:until,
60
- s(:call, s(:call, nil, :foo), :=~, s(:call, nil, :bar)),
61
- s(:call, nil, :baz), true)
57
+ it "converts a negated match condition to :until in the postfix case" do
58
+ _("baz while foo !~ bar")
59
+ .must_be_parsed_as s(:until,
60
+ s(:call, s(:call, nil, :foo), :=~, s(:call, nil, :bar)),
61
+ s(:call, nil, :baz), true)
62
62
  end
63
63
 
64
- it 'cleans up begin..end block in condition' do
65
- 'while begin foo end; bar; end'.
66
- must_be_parsed_as s(:while,
67
- s(:call, nil, :foo),
68
- s(:call, nil, :bar), true)
64
+ it "cleans up begin..end block in condition" do
65
+ _("while begin foo end; bar; end")
66
+ .must_be_parsed_as s(:while,
67
+ s(:call, nil, :foo),
68
+ s(:call, nil, :bar), true)
69
69
  end
70
70
 
71
- it 'cleans up begin..end block in condition in the postfix case' do
72
- 'foo while begin bar end'.
73
- must_be_parsed_as s(:while,
74
- s(:call, nil, :bar),
75
- s(:call, nil, :foo), true)
71
+ it "cleans up begin..end block in condition in the postfix case" do
72
+ _("foo while begin bar end")
73
+ .must_be_parsed_as s(:while,
74
+ s(:call, nil, :bar),
75
+ s(:call, nil, :foo), true)
76
76
  end
77
77
 
78
- it 'works with do and an empty body' do
79
- 'while foo do; end'.
80
- must_be_parsed_as s(:while,
81
- s(:call, nil, :foo),
82
- nil, true)
78
+ it "works with do and an empty body" do
79
+ _("while foo do; end")
80
+ .must_be_parsed_as s(:while,
81
+ s(:call, nil, :foo),
82
+ nil, true)
83
83
  end
84
84
 
85
- it 'works without do and with an empty body' do
86
- 'while foo; end'.
87
- must_be_parsed_as s(:while,
88
- s(:call, nil, :foo),
89
- nil, true)
85
+ it "works without do and with an empty body" do
86
+ _("while foo; end")
87
+ .must_be_parsed_as s(:while,
88
+ s(:call, nil, :foo),
89
+ nil, true)
90
90
  end
91
91
  end
92
92
 
93
- describe 'for the until statement' do
94
- it 'works in the prefix block case with do' do
95
- 'until foo do; bar; end'.
96
- must_be_parsed_as s(:until,
97
- s(:call, nil, :foo),
98
- s(:call, nil, :bar), true)
93
+ describe "for the until statement" do
94
+ it "works in the prefix block case with do" do
95
+ _("until foo do; bar; end")
96
+ .must_be_parsed_as s(:until,
97
+ s(:call, nil, :foo),
98
+ s(:call, nil, :bar), true)
99
99
  end
100
100
 
101
- it 'works in the prefix block case without do' do
102
- 'until foo; bar; end'.
103
- must_be_parsed_as s(:until,
104
- s(:call, nil, :foo),
105
- s(:call, nil, :bar), true)
101
+ it "works in the prefix block case without do" do
102
+ _("until foo; bar; end")
103
+ .must_be_parsed_as s(:until,
104
+ s(:call, nil, :foo),
105
+ s(:call, nil, :bar), true)
106
106
  end
107
107
 
108
- it 'works in the single-line postfix case' do
109
- 'foo until bar'.
110
- must_be_parsed_as s(:until,
111
- s(:call, nil, :bar),
112
- s(:call, nil, :foo), true)
108
+ it "works in the single-line postfix case" do
109
+ _("foo until bar")
110
+ .must_be_parsed_as s(:until,
111
+ s(:call, nil, :bar),
112
+ s(:call, nil, :foo), true)
113
113
  end
114
114
 
115
- it 'works in the block postfix case' do
116
- 'begin; foo; end until bar'.
117
- must_be_parsed_as s(:until,
118
- s(:call, nil, :bar),
119
- s(:call, nil, :foo), false)
115
+ it "works in the block postfix case" do
116
+ _("begin; foo; end until bar")
117
+ .must_be_parsed_as s(:until,
118
+ s(:call, nil, :bar),
119
+ s(:call, nil, :foo), false)
120
120
  end
121
121
 
122
- it 'handles a negative condition' do
123
- 'until not foo; bar; end'.
124
- must_be_parsed_as s(:until,
125
- s(:call, s(:call, nil, :foo), :!),
126
- s(:call, nil, :bar), true)
122
+ it "handles a negative condition" do
123
+ _("until not foo; bar; end")
124
+ .must_be_parsed_as s(:until,
125
+ s(:call, s(:call, nil, :foo), :!),
126
+ s(:call, nil, :bar), true)
127
127
  end
128
128
 
129
- it 'handles a negative condition in the postfix case' do
130
- 'foo until not bar'.
131
- must_be_parsed_as s(:until,
132
- s(:call, s(:call, nil, :bar), :!),
133
- s(:call, nil, :foo), true)
129
+ it "handles a negative condition in the postfix case" do
130
+ _("foo until not bar")
131
+ .must_be_parsed_as s(:until,
132
+ s(:call, s(:call, nil, :bar), :!),
133
+ s(:call, nil, :foo), true)
134
134
  end
135
135
 
136
- it 'converts a negated match condition to :while' do
137
- 'until foo !~ bar; baz; end'.
138
- must_be_parsed_as s(:while,
139
- s(:call, s(:call, nil, :foo), :=~, s(:call, nil, :bar)),
140
- s(:call, nil, :baz), true)
136
+ it "converts a negated match condition to :while" do
137
+ _("until foo !~ bar; baz; end")
138
+ .must_be_parsed_as s(:while,
139
+ s(:call, s(:call, nil, :foo), :=~, s(:call, nil, :bar)),
140
+ s(:call, nil, :baz), true)
141
141
  end
142
142
 
143
- it 'converts a negated match condition to :while in the postfix case' do
144
- 'baz until foo !~ bar'.
145
- must_be_parsed_as s(:while,
146
- s(:call, s(:call, nil, :foo), :=~, s(:call, nil, :bar)),
147
- s(:call, nil, :baz), true)
143
+ it "converts a negated match condition to :while in the postfix case" do
144
+ _("baz until foo !~ bar")
145
+ .must_be_parsed_as s(:while,
146
+ s(:call, s(:call, nil, :foo), :=~, s(:call, nil, :bar)),
147
+ s(:call, nil, :baz), true)
148
148
  end
149
149
 
150
- it 'cleans up begin..end block in condition' do
151
- 'until begin foo end; bar; end'.
152
- must_be_parsed_as s(:until,
153
- s(:call, nil, :foo),
154
- s(:call, nil, :bar), true)
150
+ it "cleans up begin..end block in condition" do
151
+ _("until begin foo end; bar; end")
152
+ .must_be_parsed_as s(:until,
153
+ s(:call, nil, :foo),
154
+ s(:call, nil, :bar), true)
155
155
  end
156
156
 
157
- it 'cleans up begin..end block in condition in the postfix case' do
158
- 'foo until begin bar end'.
159
- must_be_parsed_as s(:until,
160
- s(:call, nil, :bar),
161
- s(:call, nil, :foo), true)
157
+ it "cleans up begin..end block in condition in the postfix case" do
158
+ _("foo until begin bar end")
159
+ .must_be_parsed_as s(:until,
160
+ s(:call, nil, :bar),
161
+ s(:call, nil, :foo), true)
162
162
  end
163
163
  end
164
164
 
165
- describe 'for the for statement' do
166
- it 'works with do' do
167
- 'for foo in bar do; baz; end'.
168
- must_be_parsed_as s(:for,
169
- s(:call, nil, :bar),
170
- s(:lasgn, :foo),
171
- s(:call, nil, :baz))
172
- end
173
-
174
- it 'works without do' do
175
- 'for foo in bar; baz; end'.
176
- must_be_parsed_as s(:for,
177
- s(:call, nil, :bar),
178
- s(:lasgn, :foo),
179
- s(:call, nil, :baz))
180
- end
181
-
182
- it 'works with an empty body' do
183
- 'for foo in bar; end'.
184
- must_be_parsed_as s(:for,
185
- s(:call, nil, :bar),
186
- s(:lasgn, :foo))
187
- end
188
-
189
- it 'works with explicit multiple assignment' do
190
- 'for foo, bar in baz; end'.
191
- must_be_parsed_as s(:for,
192
- s(:call, nil, :baz),
193
- s(:masgn,
194
- s(:array,
195
- s(:lasgn, :foo),
196
- s(:lasgn, :bar))))
197
- end
198
-
199
- it 'works with multiple assignment with trailing comma' do
200
- 'for foo, in bar; end'.
201
- must_be_parsed_as s(:for,
202
- s(:call, nil, :bar),
203
- s(:masgn,
204
- s(:array,
205
- s(:lasgn, :foo))))
165
+ describe "for the for statement" do
166
+ it "works with do" do
167
+ _("for foo in bar do; baz; end")
168
+ .must_be_parsed_as s(:for,
169
+ s(:call, nil, :bar),
170
+ s(:lasgn, :foo),
171
+ s(:call, nil, :baz))
172
+ end
173
+
174
+ it "works without do" do
175
+ _("for foo in bar; baz; end")
176
+ .must_be_parsed_as s(:for,
177
+ s(:call, nil, :bar),
178
+ s(:lasgn, :foo),
179
+ s(:call, nil, :baz))
180
+ end
181
+
182
+ it "works with an empty body" do
183
+ _("for foo in bar; end")
184
+ .must_be_parsed_as s(:for,
185
+ s(:call, nil, :bar),
186
+ s(:lasgn, :foo))
187
+ end
188
+
189
+ it "works with explicit multiple assignment" do
190
+ _("for foo, bar in baz; end")
191
+ .must_be_parsed_as s(:for,
192
+ s(:call, nil, :baz),
193
+ s(:masgn,
194
+ s(:array,
195
+ s(:lasgn, :foo),
196
+ s(:lasgn, :bar))))
197
+ end
198
+
199
+ it "works with multiple assignment with trailing comma" do
200
+ _("for foo, in bar; end")
201
+ .must_be_parsed_as s(:for,
202
+ s(:call, nil, :bar),
203
+ s(:masgn,
204
+ s(:array,
205
+ s(:lasgn, :foo))))
206
206
  end
207
207
  end
208
208
  end
@@ -1,266 +1,266 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
3
+ require File.expand_path("../../test_helper.rb", File.dirname(__FILE__))
4
4
 
5
5
  describe RipperRubyParser::SexpHandlers::MethodCalls do
6
- describe 'when parsing with RipperRubyParser::Parser#parse' do
7
- describe 'for method calls' do
8
- describe 'without a receiver' do
9
- it 'works without parentheses' do
10
- 'foo bar'.
11
- must_be_parsed_as s(:call, nil, :foo,
12
- s(:call, nil, :bar))
6
+ describe "when parsing with RipperRubyParser::Parser#parse" do
7
+ describe "for method calls" do
8
+ describe "without a receiver" do
9
+ it "works without parentheses" do
10
+ _("foo bar")
11
+ .must_be_parsed_as s(:call, nil, :foo,
12
+ s(:call, nil, :bar))
13
13
  end
14
14
 
15
- it 'works with parentheses' do
16
- 'foo(bar)'.
17
- must_be_parsed_as s(:call, nil, :foo,
18
- s(:call, nil, :bar))
15
+ it "works with parentheses" do
16
+ _("foo(bar)")
17
+ .must_be_parsed_as s(:call, nil, :foo,
18
+ s(:call, nil, :bar))
19
19
  end
20
20
 
21
- it 'works with an empty parameter list and no parentheses' do
22
- 'foo'.
23
- must_be_parsed_as s(:call, nil, :foo)
21
+ it "works with an empty parameter list and no parentheses" do
22
+ _("foo")
23
+ .must_be_parsed_as s(:call, nil, :foo)
24
24
  end
25
25
 
26
- it 'works with parentheses around an empty parameter list' do
27
- 'foo()'.
28
- must_be_parsed_as s(:call, nil, :foo)
26
+ it "works with parentheses around an empty parameter list" do
27
+ _("foo()")
28
+ .must_be_parsed_as s(:call, nil, :foo)
29
29
  end
30
30
 
31
- it 'works for methods ending in a question mark' do
32
- 'foo?'.
33
- must_be_parsed_as s(:call, nil, :foo?)
31
+ it "works for methods ending in a question mark" do
32
+ _("foo?")
33
+ .must_be_parsed_as s(:call, nil, :foo?)
34
34
  end
35
35
 
36
- it 'works with nested calls without parentheses' do
37
- 'foo bar baz'.
38
- must_be_parsed_as s(:call, nil, :foo,
39
- s(:call, nil, :bar,
40
- s(:call, nil, :baz)))
36
+ it "works with nested calls without parentheses" do
37
+ _("foo bar baz")
38
+ .must_be_parsed_as s(:call, nil, :foo,
39
+ s(:call, nil, :bar,
40
+ s(:call, nil, :baz)))
41
41
  end
42
42
 
43
- it 'works with a non-final splat argument' do
44
- 'foo(bar, *baz, qux)'.
45
- must_be_parsed_as s(:call,
46
- nil,
47
- :foo,
48
- s(:call, nil, :bar),
49
- s(:splat, s(:call, nil, :baz)),
50
- s(:call, nil, :qux))
43
+ it "works with a non-final splat argument" do
44
+ _("foo(bar, *baz, qux)")
45
+ .must_be_parsed_as s(:call,
46
+ nil,
47
+ :foo,
48
+ s(:call, nil, :bar),
49
+ s(:splat, s(:call, nil, :baz)),
50
+ s(:call, nil, :qux))
51
51
  end
52
52
 
53
- it 'works with a splat argument followed by several regular arguments' do
54
- 'foo(bar, *baz, qux, quuz)'.
55
- must_be_parsed_as s(:call,
56
- nil,
57
- :foo,
58
- s(:call, nil, :bar),
59
- s(:splat, s(:call, nil, :baz)),
60
- s(:call, nil, :qux),
61
- s(:call, nil, :quuz))
53
+ it "works with a splat argument followed by several regular arguments" do
54
+ _("foo(bar, *baz, qux, quuz)")
55
+ .must_be_parsed_as s(:call,
56
+ nil,
57
+ :foo,
58
+ s(:call, nil, :bar),
59
+ s(:splat, s(:call, nil, :baz)),
60
+ s(:call, nil, :qux),
61
+ s(:call, nil, :quuz))
62
62
  end
63
63
 
64
- it 'works with a named argument' do
65
- 'foo(bar, baz: qux)'.
66
- must_be_parsed_as s(:call,
67
- nil,
68
- :foo,
69
- s(:call, nil, :bar),
70
- s(:hash, s(:lit, :baz), s(:call, nil, :qux)))
64
+ it "works with a named argument" do
65
+ _("foo(bar, baz: qux)")
66
+ .must_be_parsed_as s(:call,
67
+ nil,
68
+ :foo,
69
+ s(:call, nil, :bar),
70
+ s(:hash, s(:lit, :baz), s(:call, nil, :qux)))
71
71
  end
72
72
 
73
- it 'works with several named arguments' do
74
- 'foo(bar, baz: qux, quux: quuz)'.
75
- must_be_parsed_as s(:call,
76
- nil,
77
- :foo,
78
- s(:call, nil, :bar),
79
- s(:hash,
80
- s(:lit, :baz), s(:call, nil, :qux),
81
- s(:lit, :quux), s(:call, nil, :quuz)))
73
+ it "works with several named arguments" do
74
+ _("foo(bar, baz: qux, quux: quuz)")
75
+ .must_be_parsed_as s(:call,
76
+ nil,
77
+ :foo,
78
+ s(:call, nil, :bar),
79
+ s(:hash,
80
+ s(:lit, :baz), s(:call, nil, :qux),
81
+ s(:lit, :quux), s(:call, nil, :quuz)))
82
82
  end
83
83
 
84
- it 'works with a double splat argument' do
85
- 'foo(bar, **baz)'.
86
- must_be_parsed_as s(:call,
87
- nil,
88
- :foo,
89
- s(:call, nil, :bar),
90
- s(:hash,
91
- s(:kwsplat, s(:call, nil, :baz))))
84
+ it "works with a double splat argument" do
85
+ _("foo(bar, **baz)")
86
+ .must_be_parsed_as s(:call,
87
+ nil,
88
+ :foo,
89
+ s(:call, nil, :bar),
90
+ s(:hash,
91
+ s(:kwsplat, s(:call, nil, :baz))))
92
92
  end
93
93
 
94
- it 'works with a named argument followed by a double splat argument' do
95
- 'foo(bar, baz: qux, **quuz)'.
96
- must_be_parsed_as s(:call,
97
- nil,
98
- :foo,
99
- s(:call, nil, :bar),
100
- s(:hash,
101
- s(:lit, :baz), s(:call, nil, :qux),
102
- s(:kwsplat, s(:call, nil, :quuz))))
94
+ it "works with a named argument followed by a double splat argument" do
95
+ _("foo(bar, baz: qux, **quuz)")
96
+ .must_be_parsed_as s(:call,
97
+ nil,
98
+ :foo,
99
+ s(:call, nil, :bar),
100
+ s(:hash,
101
+ s(:lit, :baz), s(:call, nil, :qux),
102
+ s(:kwsplat, s(:call, nil, :quuz))))
103
103
  end
104
104
  end
105
105
 
106
- describe 'with a receiver' do
107
- it 'works without parentheses' do
108
- 'foo.bar baz'.
109
- must_be_parsed_as s(:call,
110
- s(:call, nil, :foo),
111
- :bar,
112
- s(:call, nil, :baz))
106
+ describe "with a receiver" do
107
+ it "works without parentheses" do
108
+ _("foo.bar baz")
109
+ .must_be_parsed_as s(:call,
110
+ s(:call, nil, :foo),
111
+ :bar,
112
+ s(:call, nil, :baz))
113
113
  end
114
114
 
115
- it 'works with parentheses' do
116
- 'foo.bar(baz)'.
117
- must_be_parsed_as s(:call,
118
- s(:call, nil, :foo),
119
- :bar,
120
- s(:call, nil, :baz))
115
+ it "works with parentheses" do
116
+ _("foo.bar(baz)")
117
+ .must_be_parsed_as s(:call,
118
+ s(:call, nil, :foo),
119
+ :bar,
120
+ s(:call, nil, :baz))
121
121
  end
122
122
 
123
- it 'works with parentheses around a call with no parentheses' do
124
- 'foo.bar(baz qux)'.
125
- must_be_parsed_as s(:call,
126
- s(:call, nil, :foo),
127
- :bar,
128
- s(:call, nil, :baz,
129
- s(:call, nil, :qux)))
123
+ it "works with parentheses around a call with no parentheses" do
124
+ _("foo.bar(baz qux)")
125
+ .must_be_parsed_as s(:call,
126
+ s(:call, nil, :foo),
127
+ :bar,
128
+ s(:call, nil, :baz,
129
+ s(:call, nil, :qux)))
130
130
  end
131
131
 
132
- it 'works with nested calls without parentheses' do
133
- 'foo.bar baz qux'.
134
- must_be_parsed_as s(:call,
135
- s(:call, nil, :foo),
136
- :bar,
137
- s(:call, nil, :baz,
138
- s(:call, nil, :qux)))
132
+ it "works with nested calls without parentheses" do
133
+ _("foo.bar baz qux")
134
+ .must_be_parsed_as s(:call,
135
+ s(:call, nil, :foo),
136
+ :bar,
137
+ s(:call, nil, :baz,
138
+ s(:call, nil, :qux)))
139
139
  end
140
140
 
141
- it 'does not keep :begin around a method receiver' do
142
- 'begin; foo; end.bar'.
143
- must_be_parsed_as s(:call, s(:call, nil, :foo), :bar)
141
+ it "does not keep :begin around a method receiver" do
142
+ _("begin; foo; end.bar")
143
+ .must_be_parsed_as s(:call, s(:call, nil, :foo), :bar)
144
144
  end
145
145
  end
146
146
 
147
- describe 'for collection indexing' do
148
- it 'works in the simple case' do
149
- 'foo[bar]'.
150
- must_be_parsed_as s(:call,
151
- s(:call, nil, :foo),
152
- :[],
153
- s(:call, nil, :bar))
147
+ describe "for collection indexing" do
148
+ it "works in the simple case" do
149
+ _("foo[bar]")
150
+ .must_be_parsed_as s(:call,
151
+ s(:call, nil, :foo),
152
+ :[],
153
+ s(:call, nil, :bar))
154
154
  end
155
155
 
156
- it 'works without any indexes' do
157
- 'foo[]'.must_be_parsed_as s(:call, s(:call, nil, :foo),
158
- :[])
156
+ it "works without any indexes" do
157
+ _("foo[]").must_be_parsed_as s(:call, s(:call, nil, :foo),
158
+ :[])
159
159
  end
160
160
 
161
- it 'works with self[]' do
162
- 'self[foo]'.must_be_parsed_as s(:call, s(:self), :[],
163
- s(:call, nil, :foo))
161
+ it "works with self[]" do
162
+ _("self[foo]").must_be_parsed_as s(:call, s(:self), :[],
163
+ s(:call, nil, :foo))
164
164
  end
165
165
  end
166
166
 
167
- describe 'safe call' do
168
- it 'works without arguments' do
169
- 'foo&.bar'.must_be_parsed_as s(:safe_call, s(:call, nil, :foo), :bar)
167
+ describe "safe call" do
168
+ it "works without arguments" do
169
+ _("foo&.bar").must_be_parsed_as s(:safe_call, s(:call, nil, :foo), :bar)
170
170
  end
171
171
 
172
- it 'works with arguments' do
173
- 'foo&.bar baz'.
174
- must_be_parsed_as s(:safe_call,
175
- s(:call, nil, :foo),
176
- :bar,
177
- s(:call, nil, :baz))
172
+ it "works with arguments" do
173
+ _("foo&.bar baz")
174
+ .must_be_parsed_as s(:safe_call,
175
+ s(:call, nil, :foo),
176
+ :bar,
177
+ s(:call, nil, :baz))
178
178
  end
179
179
  end
180
180
 
181
- describe 'with blocks' do
182
- it 'works for a do block' do
183
- 'foo.bar do baz; end'.
184
- must_be_parsed_as s(:iter,
185
- s(:call,
186
- s(:call, nil, :foo),
187
- :bar),
188
- 0,
189
- s(:call, nil, :baz))
181
+ describe "with blocks" do
182
+ it "works for a do block" do
183
+ _("foo.bar do baz; end")
184
+ .must_be_parsed_as s(:iter,
185
+ s(:call,
186
+ s(:call, nil, :foo),
187
+ :bar),
188
+ 0,
189
+ s(:call, nil, :baz))
190
190
  end
191
191
 
192
- it 'works for a do block with several statements' do
193
- 'foo.bar do baz; qux; end'.
194
- must_be_parsed_as s(:iter,
195
- s(:call,
196
- s(:call, nil, :foo),
197
- :bar),
198
- 0,
199
- s(:block,
200
- s(:call, nil, :baz),
201
- s(:call, nil, :qux)))
192
+ it "works for a do block with several statements" do
193
+ _("foo.bar do baz; qux; end")
194
+ .must_be_parsed_as s(:iter,
195
+ s(:call,
196
+ s(:call, nil, :foo),
197
+ :bar),
198
+ 0,
199
+ s(:block,
200
+ s(:call, nil, :baz),
201
+ s(:call, nil, :qux)))
202
202
  end
203
203
  end
204
204
  end
205
205
 
206
- describe 'for calls to super' do
207
- specify { 'super'.must_be_parsed_as s(:zsuper) }
206
+ describe "for calls to super" do
207
+ specify { _("super").must_be_parsed_as s(:zsuper) }
208
208
  specify do
209
- 'super foo'.must_be_parsed_as s(:super,
210
- s(:call, nil, :foo))
209
+ _("super foo").must_be_parsed_as s(:super,
210
+ s(:call, nil, :foo))
211
211
  end
212
212
  specify do
213
- 'super foo, bar'.must_be_parsed_as s(:super,
214
- s(:call, nil, :foo),
215
- s(:call, nil, :bar))
213
+ _("super foo, bar").must_be_parsed_as s(:super,
214
+ s(:call, nil, :foo),
215
+ s(:call, nil, :bar))
216
216
  end
217
217
  specify do
218
- 'super foo, *bar'.must_be_parsed_as s(:super,
219
- s(:call, nil, :foo),
220
- s(:splat,
221
- s(:call, nil, :bar)))
218
+ _("super foo, *bar").must_be_parsed_as s(:super,
219
+ s(:call, nil, :foo),
220
+ s(:splat,
221
+ s(:call, nil, :bar)))
222
222
  end
223
223
  specify do
224
- 'super foo, *bar, &baz'.
225
- must_be_parsed_as s(:super,
226
- s(:call, nil, :foo),
227
- s(:splat, s(:call, nil, :bar)),
228
- s(:block_pass, s(:call, nil, :baz)))
224
+ _("super foo, *bar, &baz")
225
+ .must_be_parsed_as s(:super,
226
+ s(:call, nil, :foo),
227
+ s(:splat, s(:call, nil, :bar)),
228
+ s(:block_pass, s(:call, nil, :baz)))
229
229
  end
230
230
  end
231
231
 
232
- it 'handles calling a proc' do
233
- 'foo.()'.
234
- must_be_parsed_as s(:call, s(:call, nil, :foo), :call)
232
+ it "handles calling a proc" do
233
+ _("foo.()")
234
+ .must_be_parsed_as s(:call, s(:call, nil, :foo), :call)
235
235
  end
236
236
  end
237
237
 
238
- describe 'when processing a Sexp' do
238
+ describe "when processing a Sexp" do
239
239
  let(:processor) { RipperRubyParser::SexpProcessor.new }
240
240
 
241
- describe '#process_command_call' do
242
- it 'processes a Ruby 2.5 style period Sexp' do
241
+ describe "#process_command_call" do
242
+ it "processes a Ruby 2.5 style period Sexp" do
243
243
  sexp = s(:call,
244
- s(:vcall, s(:@ident, 'foo', s(1, 0))),
244
+ s(:vcall, s(:@ident, "foo", s(1, 0))),
245
245
  :'.',
246
- s(:@ident, 'bar', s(1, 4)))
247
- processor.process(sexp).must_equal s(:call, s(:call, nil, :foo), :bar)
246
+ s(:@ident, "bar", s(1, 4)))
247
+ _(processor.process(sexp)).must_equal s(:call, s(:call, nil, :foo), :bar)
248
248
  end
249
249
 
250
- it 'processes a Ruby 2.6 style period Sexp' do
250
+ it "processes a Ruby 2.6 style period Sexp" do
251
251
  sexp = s(:call,
252
- s(:vcall, s(:@ident, 'foo', s(1, 0))),
253
- s(:@period, '.', s(1, 3)),
254
- s(:@ident, 'bar', s(1, 4)))
255
- processor.process(sexp).must_equal s(:call, s(:call, nil, :foo), :bar)
252
+ s(:vcall, s(:@ident, "foo", s(1, 0))),
253
+ s(:@period, ".", s(1, 3)),
254
+ s(:@ident, "bar", s(1, 4)))
255
+ _(processor.process(sexp)).must_equal s(:call, s(:call, nil, :foo), :bar)
256
256
  end
257
257
 
258
- it 'raises an error for an unknown call operator' do
258
+ it "raises an error for an unknown call operator" do
259
259
  sexp = s(:call,
260
- s(:vcall, s(:@ident, 'foo', s(1, 0))),
260
+ s(:vcall, s(:@ident, "foo", s(1, 0))),
261
261
  :'>.',
262
- s(:@ident, 'bar', s(1, 4)))
263
- -> { processor.process(sexp) }.must_raise
262
+ s(:@ident, "bar", s(1, 4)))
263
+ _(-> { processor.process(sexp) }).must_raise KeyError
264
264
  end
265
265
  end
266
266
  end