ripper_ruby_parser 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,1116 +1,1105 @@
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
6
  let(:parser) { RipperRubyParser::Parser.new }
7
7
 
8
- describe '#parse' do
9
- describe 'for regexp literals' do
10
- it 'works for a simple regex literal' do
11
- '/foo/'.
12
- must_be_parsed_as s(:lit, /foo/)
8
+ describe "#parse" do
9
+ describe "for regexp literals" do
10
+ it "works for a simple regex literal" do
11
+ _("/foo/")
12
+ .must_be_parsed_as s(:lit, /foo/)
13
13
  end
14
14
 
15
- it 'works for regex literals with escaped right parenthesis' do
16
- '/\\)/'.
17
- must_be_parsed_as s(:lit, /\)/)
15
+ it "works for regex literals with escaped right parenthesis" do
16
+ _('/\\)/')
17
+ .must_be_parsed_as s(:lit, /\)/)
18
18
  end
19
19
 
20
- it 'works for regex literals with escape sequences' do
21
- '/\\)\\n\\\\/'.
22
- must_be_parsed_as s(:lit, /\)\n\\/)
20
+ it "works for regex literals with escape sequences" do
21
+ _('/\\)\\n\\\\/')
22
+ .must_be_parsed_as s(:lit, /\)\n\\/)
23
23
  end
24
24
 
25
- it 'does not fix encoding' do
26
- '/2\302\275/'.
27
- must_be_parsed_as s(:lit, /2\302\275/)
25
+ it "does not fix encoding" do
26
+ _('/2\302\275/')
27
+ .must_be_parsed_as s(:lit, /2\302\275/)
28
28
  end
29
29
 
30
- it 'works for a regex literal with the multiline flag' do
31
- '/foo/m'.
32
- must_be_parsed_as s(:lit, /foo/m)
30
+ it "works for a regex literal with the multiline flag" do
31
+ _("/foo/m")
32
+ .must_be_parsed_as s(:lit, /foo/m)
33
33
  end
34
34
 
35
- it 'works for a regex literal with the extended flag' do
36
- '/foo/x'.
37
- must_be_parsed_as s(:lit, /foo/x)
35
+ it "works for a regex literal with the extended flag" do
36
+ _("/foo/x")
37
+ .must_be_parsed_as s(:lit, /foo/x)
38
38
  end
39
39
 
40
- it 'works for a regex literal with the ignorecase flag' do
41
- '/foo/i'.
42
- must_be_parsed_as s(:lit, /foo/i)
40
+ it "works for a regex literal with the ignorecase flag" do
41
+ _("/foo/i")
42
+ .must_be_parsed_as s(:lit, /foo/i)
43
43
  end
44
44
 
45
- it 'works for a regex literal with a combination of flags' do
46
- '/foo/ixmn'.
47
- must_be_parsed_as s(:lit, /foo/mixn)
45
+ it "works for a regex literal with a combination of flags" do
46
+ _("/foo/ixmn")
47
+ .must_be_parsed_as s(:lit, /foo/mixn)
48
48
  end
49
49
 
50
- it 'works with the no-encoding flag' do
51
- '/foo/n'.
52
- must_be_parsed_as s(:lit, /foo/n)
50
+ it "works with the no-encoding flag" do
51
+ _("/foo/n")
52
+ .must_be_parsed_as s(:lit, /foo/n)
53
53
  end
54
54
 
55
- it 'works with line continuation' do
56
- "/foo\\\nbar/".
57
- must_be_parsed_as s(:lit, /foobar/)
55
+ it "works with line continuation" do
56
+ _("/foo\\\nbar/")
57
+ .must_be_parsed_as s(:lit, /foobar/)
58
58
  end
59
59
 
60
- describe 'for a %r-delimited regex literal' do
61
- it 'works for the simple case with escape sequences' do
62
- '%r[foo\nbar]'.
63
- must_be_parsed_as s(:lit, /foo\nbar/)
60
+ describe "for a %r-delimited regex literal" do
61
+ it "works for the simple case with escape sequences" do
62
+ _('%r[foo\nbar]')
63
+ .must_be_parsed_as s(:lit, /foo\nbar/)
64
64
  end
65
65
 
66
- it 'works with odd delimiters and escape sequences' do
67
- '%r_foo\nbar_'.
68
- must_be_parsed_as s(:lit, /foo\nbar/)
66
+ it "works with odd delimiters and escape sequences" do
67
+ _('%r_foo\nbar_')
68
+ .must_be_parsed_as s(:lit, /foo\nbar/)
69
69
  end
70
70
  end
71
71
 
72
- describe 'with interpolations' do
73
- it 'works for a simple interpolation' do
74
- '/foo#{bar}baz/'.
75
- must_be_parsed_as s(:dregx,
76
- 'foo',
77
- s(:evstr, s(:call, nil, :bar)),
78
- s(:str, 'baz'))
72
+ describe "with interpolations" do
73
+ it "works for a simple interpolation" do
74
+ _('/foo#{bar}baz/')
75
+ .must_be_parsed_as s(:dregx,
76
+ "foo",
77
+ s(:evstr, s(:call, nil, :bar)),
78
+ s(:str, "baz"))
79
79
  end
80
80
 
81
- it 'works for a regex literal with flags and interpolation' do
82
- '/foo#{bar}/ixm'.
83
- must_be_parsed_as s(:dregx,
84
- 'foo',
85
- s(:evstr, s(:call, nil, :bar)),
86
- 7)
81
+ it "works for a regex literal with flags and interpolation" do
82
+ _('/foo#{bar}/ixm')
83
+ .must_be_parsed_as s(:dregx,
84
+ "foo",
85
+ s(:evstr, s(:call, nil, :bar)),
86
+ 7)
87
87
  end
88
88
 
89
- it 'works with the no-encoding flag' do
90
- '/foo#{bar}/n'.
91
- must_be_parsed_as s(:dregx,
92
- 'foo',
93
- s(:evstr,
94
- s(:call, nil, :bar)), 32)
89
+ it "works with the no-encoding flag" do
90
+ _('/foo#{bar}/n')
91
+ .must_be_parsed_as s(:dregx,
92
+ "foo",
93
+ s(:evstr,
94
+ s(:call, nil, :bar)), 32)
95
95
  end
96
96
 
97
- it 'works with the unicode-encoding flag' do
98
- '/foo#{bar}/u'.
99
- must_be_parsed_as s(:dregx,
100
- 'foo',
101
- s(:evstr,
102
- s(:call, nil, :bar)), 16)
97
+ it "works with the unicode-encoding flag" do
98
+ _('/foo#{bar}/u')
99
+ .must_be_parsed_as s(:dregx,
100
+ "foo",
101
+ s(:evstr,
102
+ s(:call, nil, :bar)), 16)
103
103
  end
104
104
 
105
- it 'works with unicode flag plus other flag' do
106
- '/foo#{bar}/un'.
107
- must_be_parsed_as s(:dregx,
108
- 'foo',
109
- s(:evstr,
110
- s(:call, nil, :bar)), 48)
105
+ it "works with unicode flag plus other flag" do
106
+ _('/foo#{bar}/un')
107
+ .must_be_parsed_as s(:dregx,
108
+ "foo",
109
+ s(:evstr,
110
+ s(:call, nil, :bar)), 48)
111
111
  end
112
112
 
113
- it 'works with the euc-encoding flag' do
114
- '/foo#{bar}/e'.
115
- must_be_parsed_as s(:dregx,
116
- 'foo',
117
- s(:evstr,
118
- s(:call, nil, :bar)), 16)
113
+ it "works with the euc-encoding flag" do
114
+ _('/foo#{bar}/e')
115
+ .must_be_parsed_as s(:dregx,
116
+ "foo",
117
+ s(:evstr,
118
+ s(:call, nil, :bar)), 16)
119
119
  end
120
120
 
121
- it 'works with the sjis-encoding flag' do
122
- '/foo#{bar}/s'.
123
- must_be_parsed_as s(:dregx,
124
- 'foo',
125
- s(:evstr,
126
- s(:call, nil, :bar)), 16)
121
+ it "works with the sjis-encoding flag" do
122
+ _('/foo#{bar}/s')
123
+ .must_be_parsed_as s(:dregx,
124
+ "foo",
125
+ s(:evstr,
126
+ s(:call, nil, :bar)), 16)
127
127
  end
128
128
 
129
- it 'works for a regex literal with interpolate-once flag' do
130
- '/foo#{bar}/o'.
131
- must_be_parsed_as s(:dregx_once,
132
- 'foo',
133
- s(:evstr, s(:call, nil, :bar)))
129
+ it "works for a regex literal with interpolate-once flag" do
130
+ _('/foo#{bar}/o')
131
+ .must_be_parsed_as s(:dregx_once,
132
+ "foo",
133
+ s(:evstr, s(:call, nil, :bar)))
134
134
  end
135
135
 
136
- it 'works with an empty interpolation' do
137
- '/foo#{}bar/'.
138
- must_be_parsed_as s(:dregx,
139
- 'foo',
140
- s(:evstr),
141
- s(:str, 'bar'))
136
+ it "works with an empty interpolation" do
137
+ _('/foo#{}bar/')
138
+ .must_be_parsed_as s(:dregx,
139
+ "foo",
140
+ s(:evstr),
141
+ s(:str, "bar"))
142
142
  end
143
143
 
144
- describe 'containing just a literal string' do
145
- it 'performs the interpolation when it is at the end' do
146
- '/foo#{"bar"}/'.must_be_parsed_as s(:lit, /foobar/)
144
+ describe "containing just a literal string" do
145
+ it "performs the interpolation when it is at the end" do
146
+ _('/foo#{"bar"}/').must_be_parsed_as s(:lit, /foobar/)
147
147
  end
148
148
 
149
- it 'performs the interpolation when it is in the middle' do
150
- '/foo#{"bar"}baz/'.must_be_parsed_as s(:lit, /foobarbaz/)
149
+ it "performs the interpolation when it is in the middle" do
150
+ _('/foo#{"bar"}baz/').must_be_parsed_as s(:lit, /foobarbaz/)
151
151
  end
152
152
 
153
- it 'performs the interpolation when it is at the start' do
154
- '/#{"foo"}bar/'.must_be_parsed_as s(:lit, /foobar/)
153
+ it "performs the interpolation when it is at the start" do
154
+ _('/#{"foo"}bar/').must_be_parsed_as s(:lit, /foobar/)
155
155
  end
156
156
  end
157
157
  end
158
158
  end
159
159
 
160
- describe 'for string literals' do
161
- it 'works for empty strings' do
162
- "''".
163
- must_be_parsed_as s(:str, '')
160
+ describe "for string literals" do
161
+ it "works for empty strings" do
162
+ _("''")
163
+ .must_be_parsed_as s(:str, "")
164
164
  end
165
165
 
166
- it 'sets the encoding for literal strings to utf8 even if ascii would do' do
166
+ it "sets the encoding for literal strings to utf8 even if ascii would do" do
167
167
  parser = RipperRubyParser::Parser.new
168
168
  result = parser.parse '"foo"'
169
- result.must_equal s(:str, 'foo')
170
- result[1].encoding.to_s.must_equal 'UTF-8'
169
+ _(result).must_equal s(:str, "foo")
170
+ _(result[1].encoding.to_s).must_equal "UTF-8"
171
171
  end
172
172
 
173
- it 'handles line breaks within double-quoted strings' do
174
- "\"foo\nbar\"".
175
- must_be_parsed_as s(:str, "foo\nbar")
173
+ it "handles line breaks within double-quoted strings" do
174
+ _("\"foo\nbar\"")
175
+ .must_be_parsed_as s(:str, "foo\nbar")
176
176
  end
177
177
 
178
- it 'handles line continuation with double-quoted strings' do
179
- "\"foo\\\nbar\"".
180
- must_be_parsed_as s(:str, 'foobar')
178
+ it "handles line continuation with double-quoted strings" do
179
+ _("\"foo\\\nbar\"")
180
+ .must_be_parsed_as s(:str, "foobar")
181
181
  end
182
182
 
183
- it 'escapes line continuation with double-quoted strings' do
184
- "\"foo\\\\\nbar\"".
185
- must_be_parsed_as s(:str, "foo\\\nbar")
183
+ it "escapes line continuation with double-quoted strings" do
184
+ _("\"foo\\\\\nbar\"")
185
+ .must_be_parsed_as s(:str, "foo\\\nbar")
186
186
  end
187
187
 
188
- describe 'with double-quoted strings with escape sequences' do
189
- it 'works for strings with escape sequences' do
190
- '"\\n"'.
191
- must_be_parsed_as s(:str, "\n")
188
+ describe "with double-quoted strings with escape sequences" do
189
+ it "works for strings with escape sequences" do
190
+ _('"\\n"')
191
+ .must_be_parsed_as s(:str, "\n")
192
192
  end
193
193
 
194
- it 'works for strings with useless escape sequences' do
195
- '"F\\OO"'.
196
- must_be_parsed_as s(:str, 'FOO')
194
+ it "works for strings with useless escape sequences" do
195
+ _('"F\\OO"')
196
+ .must_be_parsed_as s(:str, "FOO")
197
197
  end
198
198
 
199
- it 'works for strings with escaped backslashes' do
200
- '"\\\\n"'.
201
- must_be_parsed_as s(:str, '\\n')
199
+ it "works for strings with escaped backslashes" do
200
+ _('"\\\\n"')
201
+ .must_be_parsed_as s(:str, '\\n')
202
202
  end
203
203
 
204
- it 'works for a representation of a regex literal with escaped right parenthesis' do
205
- '"/\\\\)/"'.
206
- must_be_parsed_as s(:str, '/\\)/')
204
+ it "works for a representation of a regex literal with escaped right parenthesis" do
205
+ _('"/\\\\)/"')
206
+ .must_be_parsed_as s(:str, '/\\)/')
207
207
  end
208
208
 
209
- it 'works for a uselessly escaped right parenthesis' do
210
- '"/\\)/"'.
211
- must_be_parsed_as s(:str, '/)/')
209
+ it "works for a uselessly escaped right parenthesis" do
210
+ _('"/\\)/"')
211
+ .must_be_parsed_as s(:str, "/)/")
212
212
  end
213
213
 
214
- it 'works for a string containing escaped quotes' do
215
- '"\\""'.
216
- must_be_parsed_as s(:str, '"')
214
+ it "works for a string containing escaped quotes" do
215
+ _('"\\""')
216
+ .must_be_parsed_as s(:str, '"')
217
217
  end
218
218
 
219
- it 'works with hex escapes' do
220
- '"\\x36"'.must_be_parsed_as s(:str, '6')
221
- '"\\x4a"'.must_be_parsed_as s(:str, 'J')
222
- '"\\x4A"'.must_be_parsed_as s(:str, 'J')
223
- '"\\x3Z"'.must_be_parsed_as s(:str, "\x03Z")
219
+ it "works with hex escapes" do
220
+ _('"\\x36"').must_be_parsed_as s(:str, "6")
221
+ _('"\\x4a"').must_be_parsed_as s(:str, "J")
222
+ _('"\\x4A"').must_be_parsed_as s(:str, "J")
223
+ _('"\\x3Z"').must_be_parsed_as s(:str, "\x03Z")
224
224
  end
225
225
 
226
- it 'works with single-letter escapes' do
227
- '"foo\\abar"'.must_be_parsed_as s(:str, "foo\abar")
228
- '"foo\\bbar"'.must_be_parsed_as s(:str, "foo\bbar")
229
- '"foo\\ebar"'.must_be_parsed_as s(:str, "foo\ebar")
230
- '"foo\\fbar"'.must_be_parsed_as s(:str, "foo\fbar")
231
- '"foo\\nbar"'.must_be_parsed_as s(:str, "foo\nbar")
232
- '"foo\\rbar"'.must_be_parsed_as s(:str, "foo\rbar")
233
- '"foo\\sbar"'.must_be_parsed_as s(:str, "foo\sbar")
234
- '"foo\\tbar"'.must_be_parsed_as s(:str, "foo\tbar")
235
- '"foo\\vbar"'.must_be_parsed_as s(:str, "foo\vbar")
226
+ it "works with single-letter escapes" do
227
+ _('"foo\\abar"').must_be_parsed_as s(:str, "foo\abar")
228
+ _('"foo\\bbar"').must_be_parsed_as s(:str, "foo\bbar")
229
+ _('"foo\\ebar"').must_be_parsed_as s(:str, "foo\ebar")
230
+ _('"foo\\fbar"').must_be_parsed_as s(:str, "foo\fbar")
231
+ _('"foo\\nbar"').must_be_parsed_as s(:str, "foo\nbar")
232
+ _('"foo\\rbar"').must_be_parsed_as s(:str, "foo\rbar")
233
+ _('"foo\\sbar"').must_be_parsed_as s(:str, "foo\sbar")
234
+ _('"foo\\tbar"').must_be_parsed_as s(:str, "foo\tbar")
235
+ _('"foo\\vbar"').must_be_parsed_as s(:str, "foo\vbar")
236
236
  end
237
237
 
238
- it 'works with octal number escapes' do
239
- '"foo\\123bar"'.must_be_parsed_as s(:str, "foo\123bar")
240
- '"foo\\23bar"'.must_be_parsed_as s(:str, "foo\023bar")
241
- '"foo\\3bar"'.must_be_parsed_as s(:str, "foo\003bar")
238
+ it "works with octal number escapes" do
239
+ _('"foo\\123bar"').must_be_parsed_as s(:str, "foo\123bar")
240
+ _('"foo\\23bar"').must_be_parsed_as s(:str, "foo\023bar")
241
+ _('"foo\\3bar"').must_be_parsed_as s(:str, "foo\003bar")
242
242
 
243
- '"foo\\118bar"'.must_be_parsed_as s(:str, "foo\0118bar")
244
- '"foo\\18bar"'.must_be_parsed_as s(:str, "foo\0018bar")
243
+ _('"foo\\118bar"').must_be_parsed_as s(:str, "foo\0118bar")
244
+ _('"foo\\18bar"').must_be_parsed_as s(:str, "foo\0018bar")
245
245
  end
246
246
 
247
- it 'works with simple short hand control sequence escapes' do
248
- '"foo\\cabar"'.must_be_parsed_as s(:str, "foo\cabar")
249
- '"foo\\cZbar"'.must_be_parsed_as s(:str, "foo\cZbar")
247
+ it "works with simple short hand control sequence escapes" do
248
+ _('"foo\\cabar"').must_be_parsed_as s(:str, "foo\cabar")
249
+ _('"foo\\cZbar"').must_be_parsed_as s(:str, "foo\cZbar")
250
250
  end
251
251
 
252
- it 'works with simple regular control sequence escapes' do
253
- '"foo\\C-abar"'.must_be_parsed_as s(:str, "foo\C-abar")
254
- '"foo\\C-Zbar"'.must_be_parsed_as s(:str, "foo\C-Zbar")
252
+ it "works with simple regular control sequence escapes" do
253
+ _('"foo\\C-abar"').must_be_parsed_as s(:str, "foo\C-abar")
254
+ _('"foo\\C-Zbar"').must_be_parsed_as s(:str, "foo\C-Zbar")
255
255
  end
256
256
 
257
- it 'works with unicode escapes' do
258
- '"foo\\u273bbar"'.must_be_parsed_as s(:str, 'foo✻bar')
257
+ it "works with unicode escapes" do
258
+ _('"foo\\u273bbar"').must_be_parsed_as s(:str, "foo✻bar")
259
259
  end
260
260
 
261
- it 'works with unicode escapes with braces' do
262
- '"foo\\u{273b}bar"'.must_be_parsed_as s(:str, 'foo✻bar')
261
+ it "works with unicode escapes with braces" do
262
+ _('"foo\\u{273b}bar"').must_be_parsed_as s(:str, "foo✻bar")
263
263
  end
264
264
 
265
- it 'converts to unicode if possible' do
266
- '"2\302\275"'.must_be_parsed_as s(:str, '')
265
+ it "converts to unicode if possible" do
266
+ _('"2\302\275"').must_be_parsed_as s(:str, "")
267
267
  end
268
268
 
269
- it 'does not convert to unicode if result is not valid' do
270
- '"2\x82\302\275"'.
271
- must_be_parsed_as s(:str,
272
- (+"2\x82\xC2\xBD").force_encoding('ascii-8bit'))
269
+ it "does not convert to unicode if result is not valid" do
270
+ _('"2\x82\302\275"')
271
+ .must_be_parsed_as s(:str,
272
+ (+"2\x82\xC2\xBD").force_encoding("ascii-8bit"))
273
273
  end
274
274
  end
275
275
 
276
- describe 'with interpolations containing just a literal string' do
277
- it 'performs the interpolation when it is at the end' do
278
- '"foo#{"bar"}"'.must_be_parsed_as s(:str, 'foobar')
276
+ describe "with interpolations containing just a literal string" do
277
+ it "performs the interpolation when it is at the end" do
278
+ _('"foo#{"bar"}"').must_be_parsed_as s(:str, "foobar")
279
279
  end
280
280
 
281
- it 'performs the interpolation when it is in the middle' do
282
- '"foo#{"bar"}baz"'.must_be_parsed_as s(:str, 'foobarbaz')
281
+ it "performs the interpolation when it is in the middle" do
282
+ _('"foo#{"bar"}baz"').must_be_parsed_as s(:str, "foobarbaz")
283
283
  end
284
284
 
285
- it 'performs the interpolation when it is at the start' do
286
- '"#{"foo"}bar"'.must_be_parsed_as s(:str, 'foobar')
285
+ it "performs the interpolation when it is at the start" do
286
+ _('"#{"foo"}bar"').must_be_parsed_as s(:str, "foobar")
287
287
  end
288
288
  end
289
289
 
290
- describe 'with interpolations without braces' do
291
- it 'works for ivars' do
292
- "\"foo\#@bar\"".must_be_parsed_as s(:dstr,
293
- 'foo',
294
- s(:evstr, s(:ivar, :@bar)))
290
+ describe "with interpolations without braces" do
291
+ it "works for ivars" do
292
+ _("\"foo\#@bar\"").must_be_parsed_as s(:dstr,
293
+ "foo",
294
+ s(:evstr, s(:ivar, :@bar)))
295
295
  end
296
296
 
297
- it 'works for gvars' do
298
- "\"foo\#$bar\"".must_be_parsed_as s(:dstr,
299
- 'foo',
300
- s(:evstr, s(:gvar, :$bar)))
297
+ it "works for gvars" do
298
+ _("\"foo\#$bar\"").must_be_parsed_as s(:dstr,
299
+ "foo",
300
+ s(:evstr, s(:gvar, :$bar)))
301
301
  end
302
302
 
303
- it 'works for cvars' do
304
- "\"foo\#@@bar\"".must_be_parsed_as s(:dstr,
305
- 'foo',
306
- s(:evstr, s(:cvar, :@@bar)))
303
+ it "works for cvars" do
304
+ _("\"foo\#@@bar\"").must_be_parsed_as s(:dstr,
305
+ "foo",
306
+ s(:evstr, s(:cvar, :@@bar)))
307
307
  end
308
308
  end
309
309
 
310
- describe 'with interpolations with braces' do
311
- it 'works for trivial interpolated strings' do
312
- '"#{foo}"'.
313
- must_be_parsed_as s(:dstr,
314
- '',
315
- s(:evstr,
316
- s(:call, nil, :foo)))
310
+ describe "with interpolations with braces" do
311
+ it "works for trivial interpolated strings" do
312
+ _('"#{foo}"')
313
+ .must_be_parsed_as s(:dstr,
314
+ "",
315
+ s(:evstr,
316
+ s(:call, nil, :foo)))
317
317
  end
318
318
 
319
- it 'works for basic interpolated strings' do
320
- '"foo#{bar}"'.
321
- must_be_parsed_as s(:dstr,
322
- 'foo',
323
- s(:evstr,
324
- s(:call, nil, :bar)))
319
+ it "works for basic interpolated strings" do
320
+ _('"foo#{bar}"')
321
+ .must_be_parsed_as s(:dstr,
322
+ "foo",
323
+ s(:evstr,
324
+ s(:call, nil, :bar)))
325
325
  end
326
326
 
327
- it 'works for strings with several interpolations' do
328
- '"foo#{bar}baz#{qux}"'.
329
- must_be_parsed_as s(:dstr,
330
- 'foo',
331
- s(:evstr, s(:call, nil, :bar)),
332
- s(:str, 'baz'),
333
- s(:evstr, s(:call, nil, :qux)))
327
+ it "works for strings with several interpolations" do
328
+ _('"foo#{bar}baz#{qux}"')
329
+ .must_be_parsed_as s(:dstr,
330
+ "foo",
331
+ s(:evstr, s(:call, nil, :bar)),
332
+ s(:str, "baz"),
333
+ s(:evstr, s(:call, nil, :qux)))
334
334
  end
335
335
 
336
- it 'correctly handles two interpolations in a row' do
337
- "\"\#{bar}\#{qux}\"".
338
- must_be_parsed_as s(:dstr,
339
- '',
340
- s(:evstr, s(:call, nil, :bar)),
341
- s(:evstr, s(:call, nil, :qux)))
336
+ it "correctly handles two interpolations in a row" do
337
+ _("\"\#{bar}\#{qux}\"")
338
+ .must_be_parsed_as s(:dstr,
339
+ "",
340
+ s(:evstr, s(:call, nil, :bar)),
341
+ s(:evstr, s(:call, nil, :qux)))
342
342
  end
343
343
 
344
- it 'works with an empty interpolation' do
345
- "\"foo\#{}bar\"".
346
- must_be_parsed_as s(:dstr,
347
- 'foo',
348
- s(:evstr),
349
- s(:str, 'bar'))
344
+ it "works with an empty interpolation" do
345
+ _("\"foo\#{}bar\"")
346
+ .must_be_parsed_as s(:dstr,
347
+ "foo",
348
+ s(:evstr),
349
+ s(:str, "bar"))
350
350
  end
351
351
 
352
- it 'correctly handles interpolation with __FILE__ before another interpolation' do
353
- "\"foo\#{__FILE__}\#{bar}\"".
354
- must_be_parsed_as s(:dstr,
355
- 'foo(string)',
356
- s(:evstr, s(:call, nil, :bar)))
352
+ it "correctly handles interpolation with __FILE__ before another interpolation" do
353
+ _("\"foo\#{__FILE__}\#{bar}\"")
354
+ .must_be_parsed_as s(:dstr,
355
+ "foo(string)",
356
+ s(:evstr, s(:call, nil, :bar)))
357
357
  end
358
358
 
359
- it 'correctly handles interpolation with __FILE__ after another interpolation' do
360
- "\"\#{bar}foo\#{__FILE__}\"".
361
- must_be_parsed_as s(:dstr,
362
- '',
363
- s(:evstr, s(:call, nil, :bar)),
364
- s(:str, 'foo'),
365
- s(:str, '(string)'))
359
+ it "correctly handles interpolation with __FILE__ after another interpolation" do
360
+ _("\"\#{bar}foo\#{__FILE__}\"")
361
+ .must_be_parsed_as s(:dstr,
362
+ "",
363
+ s(:evstr, s(:call, nil, :bar)),
364
+ s(:str, "foo"),
365
+ s(:str, "(string)"))
366
366
  end
367
367
 
368
- it 'correctly handles nested interpolation' do
369
- '"foo#{"bar#{baz}"}"'.
370
- must_be_parsed_as s(:dstr,
371
- 'foobar',
372
- s(:evstr, s(:call, nil, :baz)))
368
+ it "correctly handles nested interpolation" do
369
+ _('"foo#{"bar#{baz}"}"')
370
+ .must_be_parsed_as s(:dstr,
371
+ "foobar",
372
+ s(:evstr, s(:call, nil, :baz)))
373
373
  end
374
374
 
375
- it 'correctly handles consecutive nested interpolation' do
376
- '"foo#{"bar#{baz}"}foo#{"bar#{baz}"}"'.
377
- must_be_parsed_as s(:dstr,
378
- 'foobar',
379
- s(:evstr, s(:call, nil, :baz)),
380
- s(:str, 'foo'),
381
- s(:str, 'bar'),
382
- s(:evstr, s(:call, nil, :baz)))
375
+ it "correctly handles consecutive nested interpolation" do
376
+ _('"foo#{"bar#{baz}"}foo#{"bar#{baz}"}"')
377
+ .must_be_parsed_as s(:dstr,
378
+ "foobar",
379
+ s(:evstr, s(:call, nil, :baz)),
380
+ s(:str, "foo"),
381
+ s(:str, "bar"),
382
+ s(:evstr, s(:call, nil, :baz)))
383
383
  end
384
384
  end
385
385
 
386
- describe 'with interpolations and escape sequences' do
387
- it 'works when interpolations are followed by escape sequences' do
388
- '"#{foo}\\n"'.
389
- must_be_parsed_as s(:dstr,
390
- '',
391
- s(:evstr, s(:call, nil, :foo)),
392
- s(:str, "\n"))
386
+ describe "with interpolations and escape sequences" do
387
+ it "works when interpolations are followed by escape sequences" do
388
+ _('"#{foo}\\n"')
389
+ .must_be_parsed_as s(:dstr,
390
+ "",
391
+ s(:evstr, s(:call, nil, :foo)),
392
+ s(:str, "\n"))
393
393
  end
394
394
 
395
- it 'works when interpolations contain a mix of other string-like literals' do
396
- '"#{[:foo, \'bar\']}\\n"'.
397
- must_be_parsed_as s(:dstr,
398
- '',
399
- s(:evstr, s(:array, s(:lit, :foo), s(:str, 'bar'))),
400
- s(:str, "\n"))
395
+ it "works when interpolations contain a mix of other string-like literals" do
396
+ _('"#{[:foo, \'bar\']}\\n"')
397
+ .must_be_parsed_as s(:dstr,
398
+ "",
399
+ s(:evstr, s(:array, s(:lit, :foo), s(:str, "bar"))),
400
+ s(:str, "\n"))
401
401
  end
402
402
 
403
- it 'converts to unicode after interpolation' do
404
- '"#{foo}2\302\275"'.
405
- must_be_parsed_as s(:dstr,
406
- '',
407
- s(:evstr, s(:call, nil, :foo)),
408
- s(:str, ''))
403
+ it "converts to unicode after interpolation" do
404
+ _('"#{foo}2\302\275"')
405
+ .must_be_parsed_as s(:dstr,
406
+ "",
407
+ s(:evstr, s(:call, nil, :foo)),
408
+ s(:str, ""))
409
409
  end
410
410
 
411
- it 'convert single null byte to unicode after interpolation' do
412
- '"#{foo}\0"'.
413
- must_be_parsed_as s(:dstr,
414
- '',
415
- s(:evstr, s(:call, nil, :foo)),
416
- s(:str, "\u0000"))
411
+ it "convert single null byte to unicode after interpolation" do
412
+ _('"#{foo}\0"')
413
+ .must_be_parsed_as s(:dstr,
414
+ "",
415
+ s(:evstr, s(:call, nil, :foo)),
416
+ s(:str, "\u0000"))
417
417
  end
418
418
 
419
- it 'converts string with null to unicode after interpolation' do
420
- '"#{foo}bar\0"'.
421
- must_be_parsed_as s(:dstr,
422
- '',
423
- s(:evstr, s(:call, nil, :foo)),
424
- s(:str, "bar\x00"))
419
+ it "converts string with null to unicode after interpolation" do
420
+ _('"#{foo}bar\0"')
421
+ .must_be_parsed_as s(:dstr,
422
+ "",
423
+ s(:evstr, s(:call, nil, :foo)),
424
+ s(:str, "bar\x00"))
425
425
  end
426
426
  end
427
427
 
428
- describe 'with single quoted strings' do
429
- it 'works with escaped single quotes' do
430
- "'foo\\'bar'".
431
- must_be_parsed_as s(:str, "foo'bar")
428
+ describe "with single quoted strings" do
429
+ it "works with escaped single quotes" do
430
+ _("'foo\\'bar'")
431
+ .must_be_parsed_as s(:str, "foo'bar")
432
432
  end
433
433
 
434
- it 'works with embedded backslashes' do
435
- "'foo\\abar'".
436
- must_be_parsed_as s(:str, 'foo\abar')
434
+ it "works with embedded backslashes" do
435
+ _("'foo\\abar'")
436
+ .must_be_parsed_as s(:str, 'foo\abar')
437
437
  end
438
438
 
439
- it 'works with escaped embedded backslashes' do
440
- "'foo\\\\abar'".
441
- must_be_parsed_as s(:str, 'foo\abar')
439
+ it "works with escaped embedded backslashes" do
440
+ _("'foo\\\\abar'")
441
+ .must_be_parsed_as s(:str, 'foo\abar')
442
442
  end
443
443
 
444
- it 'works with sequences of backslashes' do
445
- "'foo\\\\\\abar'".
446
- must_be_parsed_as s(:str, 'foo\\\\abar')
444
+ it "works with sequences of backslashes" do
445
+ _("'foo\\\\\\abar'")
446
+ .must_be_parsed_as s(:str, 'foo\\\\abar')
447
447
  end
448
448
 
449
- it 'does not process line continuation' do
450
- "'foo\\\nbar'".
451
- must_be_parsed_as s(:str, "foo\\\nbar")
449
+ it "does not process line continuation" do
450
+ _("'foo\\\nbar'")
451
+ .must_be_parsed_as s(:str, "foo\\\nbar")
452
452
  end
453
453
  end
454
454
 
455
- describe 'with %Q-delimited strings' do
456
- it 'works for the simple case' do
457
- '%Q[bar]'.
458
- must_be_parsed_as s(:str, 'bar')
455
+ describe "with %Q-delimited strings" do
456
+ it "works for the simple case" do
457
+ _("%Q[bar]")
458
+ .must_be_parsed_as s(:str, "bar")
459
459
  end
460
460
 
461
- it 'works for escape sequences' do
462
- '%Q[foo\\nbar]'.
463
- must_be_parsed_as s(:str, "foo\nbar")
461
+ it "works for escape sequences" do
462
+ _('%Q[foo\\nbar]')
463
+ .must_be_parsed_as s(:str, "foo\nbar")
464
464
  end
465
465
 
466
- it 'works for multi-line strings' do
467
- "%Q[foo\nbar]".
468
- must_be_parsed_as s(:str, "foo\nbar")
466
+ it "works for multi-line strings" do
467
+ _("%Q[foo\nbar]")
468
+ .must_be_parsed_as s(:str, "foo\nbar")
469
469
  end
470
470
 
471
- it 'handles line continuation' do
472
- "%Q[foo\\\nbar]".
473
- must_be_parsed_as s(:str, 'foobar')
471
+ it "handles line continuation" do
472
+ _("%Q[foo\\\nbar]")
473
+ .must_be_parsed_as s(:str, "foobar")
474
474
  end
475
475
  end
476
476
 
477
- describe 'with %q-delimited strings' do
478
- it 'works for the simple case' do
479
- '%q[bar]'.
480
- must_be_parsed_as s(:str, 'bar')
477
+ describe "with %q-delimited strings" do
478
+ it "works for the simple case" do
479
+ _("%q[bar]")
480
+ .must_be_parsed_as s(:str, "bar")
481
481
  end
482
482
 
483
- it 'does not handle for escape sequences' do
484
- '%q[foo\\nbar]'.
485
- must_be_parsed_as s(:str, 'foo\nbar')
483
+ it "does not handle for escape sequences" do
484
+ _('%q[foo\\nbar]')
485
+ .must_be_parsed_as s(:str, 'foo\nbar')
486
486
  end
487
487
 
488
- it 'works for multi-line strings' do
489
- "%q[foo\nbar]".
490
- must_be_parsed_as s(:str, "foo\nbar")
488
+ it "works for multi-line strings" do
489
+ _("%q[foo\nbar]")
490
+ .must_be_parsed_as s(:str, "foo\nbar")
491
491
  end
492
492
 
493
- it 'handles line continuation' do
494
- "%q[foo\\\nbar]".
495
- must_be_parsed_as s(:str, "foo\\\nbar")
493
+ it "handles line continuation" do
494
+ _("%q[foo\\\nbar]")
495
+ .must_be_parsed_as s(:str, "foo\\\nbar")
496
496
  end
497
497
  end
498
498
 
499
- describe 'with %-delimited strings' do
500
- it 'works for the simple case' do
501
- '%(bar)'.
502
- must_be_parsed_as s(:str, 'bar')
499
+ describe "with %-delimited strings" do
500
+ it "works for the simple case" do
501
+ _("%(bar)")
502
+ .must_be_parsed_as s(:str, "bar")
503
503
  end
504
504
 
505
- it 'works for escape sequences' do
506
- '%(foo\nbar)'.
507
- must_be_parsed_as s(:str, "foo\nbar")
505
+ it "works for escape sequences" do
506
+ _('%(foo\nbar)')
507
+ .must_be_parsed_as s(:str, "foo\nbar")
508
508
  end
509
509
 
510
- it 'works for multiple lines' do
511
- "%(foo\nbar)".
512
- must_be_parsed_as s(:str, "foo\nbar")
510
+ it "works for multiple lines" do
511
+ _("%(foo\nbar)")
512
+ .must_be_parsed_as s(:str, "foo\nbar")
513
513
  end
514
514
 
515
- it 'works with line continuations' do
516
- "%(foo\\\nbar)".
517
- must_be_parsed_as s(:str, 'foobar')
515
+ it "works with line continuations" do
516
+ _("%(foo\\\nbar)")
517
+ .must_be_parsed_as s(:str, "foobar")
518
518
  end
519
519
 
520
- it 'works for odd delimiters' do
521
- '%!foo\nbar!'.
522
- must_be_parsed_as s(:str, "foo\nbar")
520
+ it "works for odd delimiters" do
521
+ _('%!foo\nbar!')
522
+ .must_be_parsed_as s(:str, "foo\nbar")
523
523
  end
524
524
  end
525
525
 
526
- describe 'with string concatenation' do
527
- it 'performs the concatenation in the case of two simple literal strings' do
528
- '"foo" "bar"'.must_be_parsed_as s(:str, 'foobar')
526
+ describe "with string concatenation" do
527
+ it "performs the concatenation in the case of two simple literal strings" do
528
+ _('"foo" "bar"').must_be_parsed_as s(:str, "foobar")
529
529
  end
530
530
 
531
- it 'performs the concatenation when the right string has interpolations' do
532
- "\"foo\" \"bar\#{baz}\"".
533
- must_be_parsed_as s(:dstr,
534
- 'foobar',
535
- s(:evstr, s(:call, nil, :baz)))
531
+ it "performs the concatenation when the right string has interpolations" do
532
+ _("\"foo\" \"bar\#{baz}\"")
533
+ .must_be_parsed_as s(:dstr,
534
+ "foobar",
535
+ s(:evstr, s(:call, nil, :baz)))
536
536
  end
537
537
 
538
- describe 'when the left string has interpolations' do
539
- it 'performs the concatenation' do
540
- "\"foo\#{bar}\" \"baz\"".
541
- must_be_parsed_as s(:dstr,
542
- 'foo',
543
- s(:evstr, s(:call, nil, :bar)),
544
- s(:str, 'baz'))
538
+ describe "when the left string has interpolations" do
539
+ it "performs the concatenation" do
540
+ _("\"foo\#{bar}\" \"baz\"")
541
+ .must_be_parsed_as s(:dstr,
542
+ "foo",
543
+ s(:evstr, s(:call, nil, :bar)),
544
+ s(:str, "baz"))
545
545
  end
546
546
 
547
- it 'performs the concatenation with an empty string' do
548
- "\"foo\#{bar}\" \"\"".
549
- must_be_parsed_as s(:dstr,
550
- 'foo',
551
- s(:evstr, s(:call, nil, :bar)),
552
- s(:str, ''))
547
+ it "performs the concatenation with an empty string" do
548
+ _("\"foo\#{bar}\" \"\"")
549
+ .must_be_parsed_as s(:dstr,
550
+ "foo",
551
+ s(:evstr, s(:call, nil, :bar)),
552
+ s(:str, ""))
553
553
  end
554
554
  end
555
555
 
556
- describe 'when both strings have interpolations' do
557
- it 'performs the concatenation' do
558
- "\"foo\#{bar}\" \"baz\#{qux}\"".
559
- must_be_parsed_as s(:dstr,
560
- 'foo',
561
- s(:evstr, s(:call, nil, :bar)),
562
- s(:str, 'baz'),
563
- s(:evstr, s(:call, nil, :qux)))
556
+ describe "when both strings have interpolations" do
557
+ it "performs the concatenation" do
558
+ _("\"foo\#{bar}\" \"baz\#{qux}\"")
559
+ .must_be_parsed_as s(:dstr,
560
+ "foo",
561
+ s(:evstr, s(:call, nil, :bar)),
562
+ s(:str, "baz"),
563
+ s(:evstr, s(:call, nil, :qux)))
564
564
  end
565
565
 
566
- it 'removes empty substrings from the concatenation' do
567
- "\"foo\#{bar}\" \"\#{qux}\"".
568
- must_be_parsed_as s(:dstr,
569
- 'foo',
570
- s(:evstr, s(:call, nil, :bar)),
571
- s(:evstr, s(:call, nil, :qux)))
566
+ it "removes empty substrings from the concatenation" do
567
+ _("\"foo\#{bar}\" \"\#{qux}\"")
568
+ .must_be_parsed_as s(:dstr,
569
+ "foo",
570
+ s(:evstr, s(:call, nil, :bar)),
571
+ s(:evstr, s(:call, nil, :qux)))
572
572
  end
573
573
  end
574
574
  end
575
575
 
576
- describe 'for heredocs' do
577
- it 'works for the simple case' do
578
- "<<FOO\nbar\nFOO".
579
- must_be_parsed_as s(:str, "bar\n")
576
+ describe "for heredocs" do
577
+ it "works for the simple case" do
578
+ _("<<FOO\nbar\nFOO")
579
+ .must_be_parsed_as s(:str, "bar\n")
580
580
  end
581
581
 
582
- it 'works with multiple lines' do
583
- "<<FOO\nbar\nbaz\nFOO".
584
- must_be_parsed_as s(:str, "bar\nbaz\n")
582
+ it "works with multiple lines" do
583
+ _("<<FOO\nbar\nbaz\nFOO")
584
+ .must_be_parsed_as s(:str, "bar\nbaz\n")
585
585
  end
586
586
 
587
- it 'works for the indentable case' do
588
- "<<-FOO\n bar\n FOO".
589
- must_be_parsed_as s(:str, " bar\n")
587
+ it "works for the indentable case" do
588
+ _("<<-FOO\n bar\n FOO")
589
+ .must_be_parsed_as s(:str, " bar\n")
590
590
  end
591
591
 
592
- it 'works for the automatically outdenting case' do
593
- " <<~FOO\n bar\n FOO".
594
- must_be_parsed_as s(:str, "bar\n")
592
+ it "works for the automatically outdenting case" do
593
+ _(" <<~FOO\n bar\n FOO")
594
+ .must_be_parsed_as s(:str, "bar\n")
595
595
  end
596
596
 
597
- it 'works for escape sequences' do
598
- "<<FOO\nbar\\tbaz\nFOO".
599
- must_be_parsed_as s(:str, "bar\tbaz\n")
597
+ it "works for escape sequences" do
598
+ _("<<FOO\nbar\\tbaz\nFOO")
599
+ .must_be_parsed_as s(:str, "bar\tbaz\n")
600
600
  end
601
601
 
602
602
  it 'converts \r to carriage returns' do
603
- "<<FOO\nbar\\rbaz\\r\nFOO".
604
- must_be_parsed_as s(:str, "bar\rbaz\r\n")
603
+ _("<<FOO\nbar\\rbaz\\r\nFOO")
604
+ .must_be_parsed_as s(:str, "bar\rbaz\r\n")
605
605
  end
606
606
 
607
- it 'does not unescape with single quoted version' do
608
- "<<'FOO'\nbar\\tbaz\nFOO".
609
- must_be_parsed_as s(:str, "bar\\tbaz\n")
607
+ it "does not unescape with single quoted version" do
608
+ _("<<'FOO'\nbar\\tbaz\nFOO")
609
+ .must_be_parsed_as s(:str, "bar\\tbaz\n")
610
610
  end
611
611
 
612
- it 'works with multiple lines with the single quoted version' do
613
- "<<'FOO'\nbar\nbaz\nFOO".
614
- must_be_parsed_as s(:str, "bar\nbaz\n")
612
+ it "works with multiple lines with the single quoted version" do
613
+ _("<<'FOO'\nbar\nbaz\nFOO")
614
+ .must_be_parsed_as s(:str, "bar\nbaz\n")
615
615
  end
616
616
 
617
- it 'does not unescape with indentable single quoted version' do
618
- "<<-'FOO'\n bar\\tbaz\n FOO".
619
- must_be_parsed_as s(:str, " bar\\tbaz\n")
617
+ it "does not unescape with indentable single quoted version" do
618
+ _("<<-'FOO'\n bar\\tbaz\n FOO")
619
+ .must_be_parsed_as s(:str, " bar\\tbaz\n")
620
620
  end
621
621
 
622
- it 'does not unescape the automatically outdenting single quoted version' do
623
- "<<~'FOO'\n bar\\tbaz\n FOO".
624
- must_be_parsed_as s(:str, "bar\\tbaz\n")
622
+ it "does not unescape the automatically outdenting single quoted version" do
623
+ _("<<~'FOO'\n bar\\tbaz\n FOO")
624
+ .must_be_parsed_as s(:str, "bar\\tbaz\n")
625
625
  end
626
626
 
627
- it 'handles line continuation' do
628
- "<<FOO\nbar\\\nbaz\nFOO".
629
- must_be_parsed_as s(:str, "barbaz\n")
627
+ it "handles line continuation" do
628
+ _("<<FOO\nbar\\\nbaz\nFOO")
629
+ .must_be_parsed_as s(:str, "barbaz\n")
630
630
  end
631
631
 
632
- it 'escapes line continuation' do
633
- "<<FOO\nbar\\\\\nbaz\nFOO".
634
- must_be_parsed_as s(:str, "bar\\\nbaz\n")
632
+ it "escapes line continuation" do
633
+ _("<<FOO\nbar\\\\\nbaz\nFOO")
634
+ .must_be_parsed_as s(:str, "bar\\\nbaz\n")
635
635
  end
636
636
 
637
- it 'converts to unicode' do
638
- "<<FOO\n2\\302\\275\nFOO".
639
- must_be_parsed_as s(:str, "2½\n")
637
+ it "converts to unicode" do
638
+ _("<<FOO\n2\\302\\275\nFOO")
639
+ .must_be_parsed_as s(:str, "2½\n")
640
640
  end
641
641
 
642
- it 'handles interpolation' do
643
- "<<FOO\n\#{bar}\nFOO".
644
- must_be_parsed_as s(:dstr, '',
645
- s(:evstr, s(:call, nil, :bar)),
646
- s(:str, "\n"))
642
+ it "handles interpolation" do
643
+ _("<<FOO\n\#{bar}\nFOO")
644
+ .must_be_parsed_as s(:dstr, "",
645
+ s(:evstr, s(:call, nil, :bar)),
646
+ s(:str, "\n"))
647
647
  end
648
648
 
649
- it 'handles line continuation after interpolation' do
650
- "<<FOO\n\#{bar}\nbaz\\\nqux\nFOO".
651
- must_be_parsed_as s(:dstr, '',
652
- s(:evstr, s(:call, nil, :bar)),
653
- s(:str, "\nbazqux\n"))
649
+ it "handles line continuation after interpolation" do
650
+ _("<<FOO\n\#{bar}\nbaz\\\nqux\nFOO")
651
+ .must_be_parsed_as s(:dstr, "",
652
+ s(:evstr, s(:call, nil, :bar)),
653
+ s(:str, "\nbazqux\n"))
654
654
  end
655
655
 
656
- it 'handles line continuation after interpolation for the indentable case' do
657
- "<<-FOO\n\#{bar}\nbaz\\\nqux\nFOO".
658
- must_be_parsed_as s(:dstr, '',
659
- s(:evstr, s(:call, nil, :bar)),
660
- s(:str, "\nbazqux\n"))
656
+ it "handles line continuation after interpolation for the indentable case" do
657
+ _("<<-FOO\n\#{bar}\nbaz\\\nqux\nFOO")
658
+ .must_be_parsed_as s(:dstr, "",
659
+ s(:evstr, s(:call, nil, :bar)),
660
+ s(:str, "\nbazqux\n"))
661
661
  end
662
662
  end
663
663
  end
664
664
 
665
- describe 'for word list literals with %w delimiter' do
666
- it 'works for the simple case' do
667
- '%w(foo bar)'.
668
- must_be_parsed_as s(:array, s(:str, 'foo'), s(:str, 'bar'))
665
+ describe "for word list literals with %w delimiter" do
666
+ it "works for the simple case" do
667
+ _("%w(foo bar)")
668
+ .must_be_parsed_as s(:array, s(:str, "foo"), s(:str, "bar"))
669
669
  end
670
670
 
671
- it 'does not perform interpolation' do
672
- '%w(foo\\nbar baz)'.
673
- must_be_parsed_as s(:array, s(:str, 'foo\\nbar'), s(:str, 'baz'))
671
+ it "does not perform interpolation" do
672
+ _('%w(foo\\nbar baz)')
673
+ .must_be_parsed_as s(:array, s(:str, 'foo\\nbar'), s(:str, "baz"))
674
674
  end
675
675
 
676
- it 'handles line continuation' do
677
- "%w(foo\\\nbar baz)".
678
- must_be_parsed_as s(:array, s(:str, "foo\nbar"), s(:str, 'baz'))
676
+ it "handles line continuation" do
677
+ _("%w(foo\\\nbar baz)")
678
+ .must_be_parsed_as s(:array, s(:str, "foo\nbar"), s(:str, "baz"))
679
679
  end
680
680
 
681
- it 'handles escaped spaces' do
682
- '%w(foo bar\ baz)'.
683
- must_be_parsed_as s(:array, s(:str, 'foo'), s(:str, 'bar baz'))
681
+ it "handles escaped spaces" do
682
+ _('%w(foo bar\ baz)')
683
+ .must_be_parsed_as s(:array, s(:str, "foo"), s(:str, "bar baz"))
684
684
  end
685
685
  end
686
686
 
687
- describe 'for word list literals with %W delimiter' do
688
- it 'works for the simple case' do
689
- '%W(foo bar)'.
690
- must_be_parsed_as s(:array, s(:str, 'foo'), s(:str, 'bar'))
687
+ describe "for word list literals with %W delimiter" do
688
+ it "works for the simple case" do
689
+ _("%W(foo bar)")
690
+ .must_be_parsed_as s(:array, s(:str, "foo"), s(:str, "bar"))
691
691
  end
692
692
 
693
- it 'handles escaped spaces' do
694
- '%W(foo bar\ baz)'.
695
- must_be_parsed_as s(:array, s(:str, 'foo'), s(:str, 'bar baz'))
693
+ it "handles escaped spaces" do
694
+ _('%W(foo bar\ baz)')
695
+ .must_be_parsed_as s(:array, s(:str, "foo"), s(:str, "bar baz"))
696
696
  end
697
697
 
698
- it 'correctly handles interpolation' do
699
- "%W(foo \#{bar} baz)".
700
- must_be_parsed_as s(:array,
701
- s(:str, 'foo'),
702
- s(:dstr, '', s(:evstr, s(:call, nil, :bar))),
703
- s(:str, 'baz'))
698
+ it "correctly handles interpolation" do
699
+ _("%W(foo \#{bar} baz)")
700
+ .must_be_parsed_as s(:array,
701
+ s(:str, "foo"),
702
+ s(:dstr, "", s(:evstr, s(:call, nil, :bar))),
703
+ s(:str, "baz"))
704
704
  end
705
705
 
706
- it 'correctly handles braceless interpolation' do
707
- "%W(foo \#@bar baz)".
708
- must_be_parsed_as s(:array,
709
- s(:str, 'foo'),
710
- s(:dstr, '', s(:evstr, s(:ivar, :@bar))),
711
- s(:str, 'baz'))
706
+ it "correctly handles braceless interpolation" do
707
+ _("%W(foo \#@bar baz)")
708
+ .must_be_parsed_as s(:array,
709
+ s(:str, "foo"),
710
+ s(:dstr, "", s(:evstr, s(:ivar, :@bar))),
711
+ s(:str, "baz"))
712
712
  end
713
713
 
714
- it 'correctly handles in-word interpolation' do
715
- "%W(foo \#{bar}baz)".
716
- must_be_parsed_as s(:array,
717
- s(:str, 'foo'),
718
- s(:dstr,
719
- '',
720
- s(:evstr, s(:call, nil, :bar)),
721
- s(:str, 'baz')))
714
+ it "correctly handles in-word interpolation" do
715
+ _("%W(foo \#{bar}baz)")
716
+ .must_be_parsed_as s(:array,
717
+ s(:str, "foo"),
718
+ s(:dstr,
719
+ "",
720
+ s(:evstr, s(:call, nil, :bar)),
721
+ s(:str, "baz")))
722
722
  end
723
723
 
724
- it 'correctly handles escape sequences' do
725
- '%W(foo\nbar baz)'.
726
- must_be_parsed_as s(:array,
727
- s(:str, "foo\nbar"),
728
- s(:str, 'baz'))
724
+ it "correctly handles escape sequences" do
725
+ _('%W(foo\nbar baz)')
726
+ .must_be_parsed_as s(:array,
727
+ s(:str, "foo\nbar"),
728
+ s(:str, "baz"))
729
729
  end
730
730
 
731
- it 'converts to unicode if possible' do
732
- '%W(2\302\275)'.must_be_parsed_as s(:array, s(:str, ''))
731
+ it "converts to unicode if possible" do
732
+ _('%W(2\302\275)').must_be_parsed_as s(:array, s(:str, ""))
733
733
  end
734
734
 
735
- it 'correctly handles line continuation' do
736
- "%W(foo\\\nbar baz)".
737
- must_be_parsed_as s(:array,
738
- s(:str, "foo\nbar"),
739
- s(:str, 'baz'))
735
+ it "correctly handles line continuation" do
736
+ _("%W(foo\\\nbar baz)")
737
+ .must_be_parsed_as s(:array,
738
+ s(:str, "foo\nbar"),
739
+ s(:str, "baz"))
740
740
  end
741
741
 
742
- it 'correctly handles multiple lines' do
743
- "%W(foo\nbar baz)".
744
- must_be_parsed_as s(:array,
745
- s(:str, 'foo'),
746
- s(:str, 'bar'),
747
- s(:str, 'baz'))
742
+ it "correctly handles multiple lines" do
743
+ _("%W(foo\nbar baz)")
744
+ .must_be_parsed_as s(:array,
745
+ s(:str, "foo"),
746
+ s(:str, "bar"),
747
+ s(:str, "baz"))
748
748
  end
749
749
  end
750
750
 
751
- describe 'for symbol list literals with %i delimiter' do
752
- it 'works for the simple case' do
753
- '%i(foo bar)'.
754
- must_be_parsed_as s(:array, s(:lit, :foo), s(:lit, :bar))
751
+ describe "for symbol list literals with %i delimiter" do
752
+ it "works for the simple case" do
753
+ _("%i(foo bar)")
754
+ .must_be_parsed_as s(:array, s(:lit, :foo), s(:lit, :bar))
755
755
  end
756
756
 
757
- it 'does not perform interpolation' do
758
- '%i(foo\\nbar baz)'.
759
- must_be_parsed_as s(:array, s(:lit, :"foo\\nbar"), s(:lit, :baz))
757
+ it "does not perform interpolation" do
758
+ _('%i(foo\\nbar baz)')
759
+ .must_be_parsed_as s(:array, s(:lit, :"foo\\nbar"), s(:lit, :baz))
760
760
  end
761
761
 
762
- it 'handles line continuation' do
763
- "%i(foo\\\nbar baz)".
764
- must_be_parsed_as s(:array, s(:lit, :"foo\nbar"), s(:lit, :baz))
762
+ it "handles line continuation" do
763
+ _("%i(foo\\\nbar baz)")
764
+ .must_be_parsed_as s(:array, s(:lit, :"foo\nbar"), s(:lit, :baz))
765
765
  end
766
766
  end
767
767
 
768
- describe 'for symbol list literals with %I delimiter' do
769
- it 'works for the simple case' do
770
- '%I(foo bar)'.
771
- must_be_parsed_as s(:array, s(:lit, :foo), s(:lit, :bar))
768
+ describe "for symbol list literals with %I delimiter" do
769
+ it "works for the simple case" do
770
+ _("%I(foo bar)")
771
+ .must_be_parsed_as s(:array, s(:lit, :foo), s(:lit, :bar))
772
772
  end
773
773
 
774
- it 'correctly handles escape sequences' do
775
- '%I(foo\nbar baz)'.
776
- must_be_parsed_as s(:array,
777
- s(:lit, :"foo\nbar"),
778
- s(:lit, :baz))
774
+ it "correctly handles escape sequences" do
775
+ _('%I(foo\nbar baz)')
776
+ .must_be_parsed_as s(:array,
777
+ s(:lit, :"foo\nbar"),
778
+ s(:lit, :baz))
779
779
  end
780
780
 
781
- it 'correctly handles interpolation' do
782
- "%I(foo \#{bar} baz)".
783
- must_be_parsed_as s(:array,
784
- s(:lit, :foo),
785
- s(:dsym, '', s(:evstr, s(:call, nil, :bar))),
786
- s(:lit, :baz))
781
+ it "correctly handles interpolation" do
782
+ _("%I(foo \#{bar} baz)")
783
+ .must_be_parsed_as s(:array,
784
+ s(:lit, :foo),
785
+ s(:dsym, "", s(:evstr, s(:call, nil, :bar))),
786
+ s(:lit, :baz))
787
787
  end
788
788
 
789
- it 'correctly handles in-word interpolation' do
790
- "%I(foo \#{bar}baz)".
791
- must_be_parsed_as s(:array,
792
- s(:lit, :foo),
793
- s(:dsym,
794
- '',
795
- s(:evstr, s(:call, nil, :bar)),
796
- s(:str, 'baz')))
789
+ it "correctly handles in-word interpolation" do
790
+ _("%I(foo \#{bar}baz)")
791
+ .must_be_parsed_as s(:array,
792
+ s(:lit, :foo),
793
+ s(:dsym,
794
+ "",
795
+ s(:evstr, s(:call, nil, :bar)),
796
+ s(:str, "baz")))
797
797
  end
798
798
 
799
- it 'correctly handles line continuation' do
800
- "%I(foo\\\nbar baz)".
801
- must_be_parsed_as s(:array,
802
- s(:lit, :"foo\nbar"),
803
- s(:lit, :baz))
799
+ it "correctly handles line continuation" do
800
+ _("%I(foo\\\nbar baz)")
801
+ .must_be_parsed_as s(:array,
802
+ s(:lit, :"foo\nbar"),
803
+ s(:lit, :baz))
804
804
  end
805
805
 
806
- it 'correctly handles multiple lines' do
807
- "%I(foo\nbar baz)".
808
- must_be_parsed_as s(:array,
809
- s(:lit, :foo),
810
- s(:lit, :bar),
811
- s(:lit, :baz))
806
+ it "correctly handles multiple lines" do
807
+ _("%I(foo\nbar baz)")
808
+ .must_be_parsed_as s(:array,
809
+ s(:lit, :foo),
810
+ s(:lit, :bar),
811
+ s(:lit, :baz))
812
812
  end
813
813
  end
814
814
 
815
- describe 'for character literals' do
816
- it 'works for simple character literals' do
817
- '?a'.
818
- must_be_parsed_as s(:str, 'a')
815
+ describe "for character literals" do
816
+ it "works for simple character literals" do
817
+ _("?a")
818
+ .must_be_parsed_as s(:str, "a")
819
819
  end
820
820
 
821
- it 'works for escaped character literals' do
822
- '?\\n'.
823
- must_be_parsed_as s(:str, "\n")
821
+ it "works for escaped character literals" do
822
+ _('?\\n')
823
+ .must_be_parsed_as s(:str, "\n")
824
824
  end
825
825
 
826
- it 'works for escaped character literals with ctrl' do
827
- '?\\C-a'.
828
- must_be_parsed_as s(:str, "\u0001")
826
+ it "works for escaped character literals with ctrl" do
827
+ _('?\\C-a')
828
+ .must_be_parsed_as s(:str, "\u0001")
829
829
  end
830
830
 
831
- it 'works for escaped character literals with meta' do
832
- '?\\M-a'.
833
- must_be_parsed_as s(:str, (+"\xE1").force_encoding('ascii-8bit'))
831
+ it "works for escaped character literals with meta" do
832
+ _('?\\M-a')
833
+ .must_be_parsed_as s(:str, (+"\xE1").force_encoding("ascii-8bit"))
834
834
  end
835
835
 
836
- it 'works for escaped character literals with meta plus shorthand ctrl' do
837
- '?\\M-\\ca'.
838
- must_be_parsed_as s(:str, (+"\x81").force_encoding('ascii-8bit'))
836
+ it "works for escaped character literals with meta plus shorthand ctrl" do
837
+ _('?\\M-\\ca')
838
+ .must_be_parsed_as s(:str, (+"\x81").force_encoding("ascii-8bit"))
839
839
  end
840
840
 
841
- it 'works for escaped character literals with shorthand ctrl plus meta' do
842
- '?\\c\\M-a'.
843
- must_be_parsed_as s(:str, (+"\x81").force_encoding('ascii-8bit'))
841
+ it "works for escaped character literals with shorthand ctrl plus meta" do
842
+ _('?\\c\\M-a')
843
+ .must_be_parsed_as s(:str, (+"\x81").force_encoding("ascii-8bit"))
844
844
  end
845
845
 
846
- it 'works for escaped character literals with meta plus ctrl' do
847
- '?\\M-\\C-a'.
848
- must_be_parsed_as s(:str, (+"\x81").force_encoding('ascii-8bit'))
846
+ it "works for escaped character literals with meta plus ctrl" do
847
+ _('?\\M-\\C-a')
848
+ .must_be_parsed_as s(:str, (+"\x81").force_encoding("ascii-8bit"))
849
849
  end
850
850
 
851
- it 'works for escaped character literals with ctrl plus meta' do
852
- '?\\C-\\M-a'.
853
- must_be_parsed_as s(:str, (+"\x81").force_encoding('ascii-8bit'))
851
+ it "works for escaped character literals with ctrl plus meta" do
852
+ _('?\\C-\\M-a')
853
+ .must_be_parsed_as s(:str, (+"\x81").force_encoding("ascii-8bit"))
854
854
  end
855
855
  end
856
856
 
857
- describe 'for symbol literals' do
858
- it 'works for simple symbols' do
859
- ':foo'.
860
- must_be_parsed_as s(:lit, :foo)
857
+ describe "for symbol literals" do
858
+ it "works for simple symbols" do
859
+ _(":foo")
860
+ .must_be_parsed_as s(:lit, :foo)
861
861
  end
862
862
 
863
- it 'works for symbols that look like instance variable names' do
864
- ':@foo'.
865
- must_be_parsed_as s(:lit, :@foo)
863
+ it "works for symbols that look like instance variable names" do
864
+ _(":@foo")
865
+ .must_be_parsed_as s(:lit, :@foo)
866
866
  end
867
867
 
868
- it 'works for symbols that look like class names' do
869
- ':Foo'.
870
- must_be_parsed_as s(:lit, :Foo)
868
+ it "works for symbols that look like class names" do
869
+ _(":Foo")
870
+ .must_be_parsed_as s(:lit, :Foo)
871
871
  end
872
872
 
873
- it 'works for symbols that look like keywords' do
874
- ':class'.must_be_parsed_as s(:lit, :class)
873
+ it "works for symbols that look like keywords" do
874
+ _(":class").must_be_parsed_as s(:lit, :class)
875
875
  end
876
876
 
877
- it 'works for :__LINE__' do
878
- ':__LINE__'.
879
- must_be_parsed_as s(:lit, :__LINE__)
877
+ it "works for :__LINE__" do
878
+ _(":__LINE__")
879
+ .must_be_parsed_as s(:lit, :__LINE__)
880
880
  end
881
881
 
882
- it 'works for :__FILE__' do
883
- ':__FILE__'.
884
- must_be_parsed_as s(:lit, :__FILE__)
882
+ it "works for :__FILE__" do
883
+ _(":__FILE__")
884
+ .must_be_parsed_as s(:lit, :__FILE__)
885
885
  end
886
886
 
887
- it 'works for a backtick symbol' do
888
- ':`'.must_be_parsed_as s(:lit, :`)
887
+ it "works for a backtick symbol" do
888
+ _(":`").must_be_parsed_as s(:lit, :`)
889
889
  end
890
890
 
891
- it 'works for simple dsyms' do
892
- ':"foo"'.
893
- must_be_parsed_as s(:lit, :foo)
891
+ it "works for simple dsyms" do
892
+ _(':"foo"')
893
+ .must_be_parsed_as s(:lit, :foo)
894
894
  end
895
895
 
896
- it 'works for dsyms with interpolations' do
897
- ':"foo#{bar}"'.
898
- must_be_parsed_as s(:dsym,
899
- 'foo',
900
- s(:evstr, s(:call, nil, :bar)))
896
+ it "works for dsyms with interpolations" do
897
+ _(':"foo#{bar}"')
898
+ .must_be_parsed_as s(:dsym,
899
+ "foo",
900
+ s(:evstr, s(:call, nil, :bar)))
901
901
  end
902
902
 
903
- it 'works for dsyms with interpolations at the start' do
904
- ':"#{bar}"'.
905
- must_be_parsed_as s(:dsym,
906
- '',
907
- s(:evstr, s(:call, nil, :bar)))
903
+ it "works for dsyms with interpolations at the start" do
904
+ _(':"#{bar}"')
905
+ .must_be_parsed_as s(:dsym,
906
+ "",
907
+ s(:evstr, s(:call, nil, :bar)))
908
908
  end
909
909
 
910
- it 'works for dsyms with escape sequences' do
911
- ':"foo\nbar"'.
912
- must_be_parsed_as s(:lit, :"foo\nbar")
910
+ it "works for dsyms with escape sequences" do
911
+ _(':"foo\nbar"')
912
+ .must_be_parsed_as s(:lit, :"foo\nbar")
913
913
  end
914
914
 
915
- it 'works for dsyms with multiple lines' do
916
- ":\"foo\nbar\"".
917
- must_be_parsed_as s(:lit, :"foo\nbar")
915
+ it "works for dsyms with multiple lines" do
916
+ _(":\"foo\nbar\"")
917
+ .must_be_parsed_as s(:lit, :"foo\nbar")
918
918
  end
919
919
 
920
- it 'works for dsyms with line continuations' do
921
- ":\"foo\\\nbar\"".
922
- must_be_parsed_as s(:lit, :foobar)
920
+ it "works for dsyms with line continuations" do
921
+ _(":\"foo\\\nbar\"")
922
+ .must_be_parsed_as s(:lit, :foobar)
923
923
  end
924
924
 
925
- it 'works with single quoted dsyms' do
926
- ":'foo'".
927
- must_be_parsed_as s(:lit, :foo)
925
+ it "works with single quoted dsyms" do
926
+ _(":'foo'")
927
+ .must_be_parsed_as s(:lit, :foo)
928
928
  end
929
929
 
930
- it 'works with single quoted dsyms with escaped single quotes' do
931
- ":'foo\\'bar'".
932
- must_be_parsed_as s(:lit, :'foo\'bar')
930
+ it "works with single quoted dsyms with escaped single quotes" do
931
+ _(":'foo\\'bar'")
932
+ .must_be_parsed_as s(:lit, :'foo\'bar')
933
933
  end
934
934
 
935
- it 'works with single quoted dsyms with multiple lines' do
936
- ":'foo\nbar'".
937
- must_be_parsed_as s(:lit, :"foo\nbar")
935
+ it "works with single quoted dsyms with multiple lines" do
936
+ _(":'foo\nbar'")
937
+ .must_be_parsed_as s(:lit, :"foo\nbar")
938
938
  end
939
939
 
940
- it 'works with single quoted dsyms with line continuations' do
941
- ":'foo\\\nbar'".
942
- must_be_parsed_as s(:lit, :"foo\\\nbar")
940
+ it "works with single quoted dsyms with line continuations" do
941
+ _(":'foo\\\nbar'")
942
+ .must_be_parsed_as s(:lit, :"foo\\\nbar")
943
943
  end
944
944
 
945
- it 'works with single quoted dsyms with embedded backslashes' do
946
- ":'foo\\abar'".
947
- must_be_parsed_as s(:lit, :"foo\\abar")
945
+ it "works with single quoted dsyms with embedded backslashes" do
946
+ _(":'foo\\abar'")
947
+ .must_be_parsed_as s(:lit, :"foo\\abar")
948
948
  end
949
949
 
950
- it 'works with barewords that need to be interpreted as symbols' do
951
- 'alias foo bar'.
952
- must_be_parsed_as s(:alias,
953
- s(:lit, :foo), s(:lit, :bar))
950
+ it "works with barewords that need to be interpreted as symbols" do
951
+ _("alias foo bar")
952
+ .must_be_parsed_as s(:alias,
953
+ s(:lit, :foo), s(:lit, :bar))
954
954
  end
955
955
 
956
- it 'assigns a line number to the result' do
957
- result = parser.parse ':foo'
958
- result.line.must_equal 1
956
+ it "assigns a line number to the result" do
957
+ result = parser.parse ":foo"
958
+ _(result.line).must_equal 1
959
959
  end
960
960
  end
961
961
 
962
- describe 'for backtick string literals' do
963
- it 'works for basic backtick strings' do
964
- '`foo`'.
965
- must_be_parsed_as s(:xstr, 'foo')
962
+ describe "for backtick string literals" do
963
+ it "works for basic backtick strings" do
964
+ _("`foo`")
965
+ .must_be_parsed_as s(:xstr, "foo")
966
966
  end
967
967
 
968
- it 'works for interpolated backtick strings' do
969
- '`foo#{bar}`'.
970
- must_be_parsed_as s(:dxstr,
971
- 'foo',
972
- s(:evstr, s(:call, nil, :bar)))
968
+ it "works for interpolated backtick strings" do
969
+ _('`foo#{bar}`')
970
+ .must_be_parsed_as s(:dxstr,
971
+ "foo",
972
+ s(:evstr, s(:call, nil, :bar)))
973
973
  end
974
974
 
975
- it 'works for backtick strings interpolated at the start' do
976
- '`#{foo}`'.
977
- must_be_parsed_as s(:dxstr, '',
978
- s(:evstr, s(:call, nil, :foo)))
975
+ it "works for backtick strings interpolated at the start" do
976
+ _('`#{foo}`')
977
+ .must_be_parsed_as s(:dxstr, "",
978
+ s(:evstr, s(:call, nil, :foo)))
979
979
  end
980
980
 
981
- it 'works for backtick strings with escape sequences' do
982
- '`foo\\n`'.
983
- must_be_parsed_as s(:xstr, "foo\n")
981
+ it "works for backtick strings with escape sequences" do
982
+ _('`foo\\n`')
983
+ .must_be_parsed_as s(:xstr, "foo\n")
984
984
  end
985
985
 
986
- it 'works for backtick strings with multiple lines' do
987
- "`foo\nbar`".
988
- must_be_parsed_as s(:xstr, "foo\nbar")
986
+ it "works for backtick strings with multiple lines" do
987
+ _("`foo\nbar`")
988
+ .must_be_parsed_as s(:xstr, "foo\nbar")
989
989
  end
990
990
 
991
- it 'works for backtick strings with line continuations' do
992
- "`foo\\\nbar`".
993
- must_be_parsed_as s(:xstr, 'foobar')
991
+ it "works for backtick strings with line continuations" do
992
+ _("`foo\\\nbar`")
993
+ .must_be_parsed_as s(:xstr, "foobar")
994
994
  end
995
995
  end
996
996
 
997
- describe 'for array literals' do
998
- it 'works for an empty array' do
999
- '[]'.
1000
- must_be_parsed_as s(:array)
997
+ describe "for array literals" do
998
+ it "works for an empty array" do
999
+ _("[]")
1000
+ .must_be_parsed_as s(:array)
1001
1001
  end
1002
1002
 
1003
- it 'works for a simple case with splat' do
1004
- '[*foo]'.
1005
- must_be_parsed_as s(:array,
1006
- s(:splat, s(:call, nil, :foo)))
1003
+ it "works for a simple case with splat" do
1004
+ _("[*foo]")
1005
+ .must_be_parsed_as s(:array,
1006
+ s(:splat, s(:call, nil, :foo)))
1007
1007
  end
1008
1008
 
1009
- it 'works for a multi-element case with splat' do
1010
- '[foo, *bar]'.
1011
- must_be_parsed_as s(:array,
1012
- s(:call, nil, :foo),
1013
- s(:splat, s(:call, nil, :bar)))
1009
+ it "works for a multi-element case with splat" do
1010
+ _("[foo, *bar]")
1011
+ .must_be_parsed_as s(:array,
1012
+ s(:call, nil, :foo),
1013
+ s(:splat, s(:call, nil, :bar)))
1014
1014
  end
1015
1015
  end
1016
1016
 
1017
- describe 'for hash literals' do
1018
- it 'works for an empty hash' do
1019
- '{}'.
1020
- must_be_parsed_as s(:hash)
1017
+ describe "for hash literals" do
1018
+ it "works for an empty hash" do
1019
+ _("{}")
1020
+ .must_be_parsed_as s(:hash)
1021
1021
  end
1022
1022
 
1023
- it 'works for a hash with one pair' do
1024
- '{foo => bar}'.
1025
- must_be_parsed_as s(:hash,
1026
- s(:call, nil, :foo),
1027
- s(:call, nil, :bar))
1023
+ it "works for a hash with one pair" do
1024
+ _("{foo => bar}")
1025
+ .must_be_parsed_as s(:hash,
1026
+ s(:call, nil, :foo),
1027
+ s(:call, nil, :bar))
1028
1028
  end
1029
1029
 
1030
- it 'works for a hash with multiple pairs' do
1031
- '{foo => bar, baz => qux}'.
1032
- must_be_parsed_as s(:hash,
1033
- s(:call, nil, :foo),
1034
- s(:call, nil, :bar),
1035
- s(:call, nil, :baz),
1036
- s(:call, nil, :qux))
1030
+ it "works for a hash with multiple pairs" do
1031
+ _("{foo => bar, baz => qux}")
1032
+ .must_be_parsed_as s(:hash,
1033
+ s(:call, nil, :foo),
1034
+ s(:call, nil, :bar),
1035
+ s(:call, nil, :baz),
1036
+ s(:call, nil, :qux))
1037
1037
  end
1038
1038
 
1039
- it 'works for a hash with label keys' do
1040
- '{foo: bar, baz: qux}'.
1041
- must_be_parsed_as s(:hash,
1042
- s(:lit, :foo),
1043
- s(:call, nil, :bar),
1044
- s(:lit, :baz),
1045
- s(:call, nil, :qux))
1039
+ it "works for a hash with label keys" do
1040
+ _("{foo: bar, baz: qux}")
1041
+ .must_be_parsed_as s(:hash,
1042
+ s(:lit, :foo),
1043
+ s(:call, nil, :bar),
1044
+ s(:lit, :baz),
1045
+ s(:call, nil, :qux))
1046
1046
  end
1047
1047
 
1048
- it 'works for a hash with dynamic label keys' do
1049
- "{'foo': bar}".
1050
- must_be_parsed_as s(:hash,
1051
- s(:lit, :foo),
1052
- s(:call, nil, :bar))
1048
+ it "works for a hash with dynamic label keys" do
1049
+ _("{'foo': bar}")
1050
+ .must_be_parsed_as s(:hash,
1051
+ s(:lit, :foo),
1052
+ s(:call, nil, :bar))
1053
1053
  end
1054
1054
 
1055
- it 'works for a hash with splat' do
1056
- '{foo: bar, baz: qux, **quux}'.
1057
- must_be_parsed_as s(:hash,
1058
- s(:lit, :foo), s(:call, nil, :bar),
1059
- s(:lit, :baz), s(:call, nil, :qux),
1060
- s(:kwsplat, s(:call, nil, :quux)))
1055
+ it "works for a hash with splat" do
1056
+ _("{foo: bar, baz: qux, **quux}")
1057
+ .must_be_parsed_as s(:hash,
1058
+ s(:lit, :foo), s(:call, nil, :bar),
1059
+ s(:lit, :baz), s(:call, nil, :qux),
1060
+ s(:kwsplat, s(:call, nil, :quux)))
1061
1061
  end
1062
1062
  end
1063
1063
 
1064
- describe 'for number literals' do
1065
- it 'works for floats' do
1066
- '3.14'.
1067
- must_be_parsed_as s(:lit, 3.14)
1064
+ describe "for number literals" do
1065
+ it "works for floats" do
1066
+ _("3.14")
1067
+ .must_be_parsed_as s(:lit, 3.14)
1068
1068
  end
1069
1069
 
1070
- it 'works for octal integer literals' do
1071
- '0700'.
1072
- must_be_parsed_as s(:lit, 448)
1070
+ it "works for octal integer literals" do
1071
+ _("0700")
1072
+ .must_be_parsed_as s(:lit, 448)
1073
1073
  end
1074
1074
 
1075
- it 'handles negative sign for integers' do
1076
- '-1'.
1077
- must_be_parsed_as s(:lit, -1)
1075
+ it "handles negative sign for integers" do
1076
+ _("-1")
1077
+ .must_be_parsed_as s(:lit, -1)
1078
1078
  end
1079
1079
 
1080
- it 'handles space after negative sign for integers' do
1081
- '-1 '.
1082
- must_be_parsed_as s(:lit, -1)
1080
+ it "handles space after negative sign for integers" do
1081
+ _("-1 ")
1082
+ .must_be_parsed_as s(:lit, -1)
1083
1083
  end
1084
1084
 
1085
- it 'handles negative sign for floats' do
1086
- '-3.14'.
1087
- must_be_parsed_as s(:lit, -3.14)
1085
+ it "handles negative sign for floats" do
1086
+ _("-3.14")
1087
+ .must_be_parsed_as s(:lit, -3.14)
1088
1088
  end
1089
1089
 
1090
- it 'handles space after negative sign for floats' do
1091
- '-3.14 '.
1092
- must_be_parsed_as s(:lit, -3.14)
1090
+ it "handles space after negative sign for floats" do
1091
+ _("-3.14 ")
1092
+ .must_be_parsed_as s(:lit, -3.14)
1093
1093
  end
1094
1094
 
1095
- it 'handles positive sign' do
1096
- '+1'.
1097
- must_be_parsed_as s(:lit, 1)
1095
+ it "handles positive sign" do
1096
+ _("+1")
1097
+ .must_be_parsed_as s(:lit, 1)
1098
1098
  end
1099
1099
 
1100
- it 'works for rationals' do
1101
- '1000r'.
1102
- must_be_parsed_as s(:lit, 1000r)
1103
- end
1104
- end
1105
-
1106
- describe 'in extra compatible mode' do
1107
- it 'converts \r to carriage returns in double-quoted strings' do
1108
- '"foo\\rbar"'.must_be_parsed_as s(:str, "foo\rbar"), extra_compatible: true
1109
- end
1110
-
1111
- it 'removes \r from heredocs' do
1112
- "<<FOO\nbar\\rbaz\\r\nFOO".
1113
- must_be_parsed_as s(:str, "barbaz\n"), extra_compatible: true
1100
+ it "works for rationals" do
1101
+ _("1000r")
1102
+ .must_be_parsed_as s(:lit, 1000r)
1114
1103
  end
1115
1104
  end
1116
1105
  end