ripper_ruby_parser 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -285,6 +285,30 @@ describe RipperRubyParser::SexpProcessor do
285
285
  nil)
286
286
  end
287
287
  end
288
+
289
+ it "processes a Ruby 2.5 style period Sexp" do
290
+ sexp = s(:call,
291
+ s(:vcall, s(:@ident, "foo", s(1, 0))),
292
+ :'.',
293
+ s(:@ident, "bar", s(1, 4)))
294
+ _(processor.process(sexp)).must_equal s(:call, s(:call, nil, :foo), :bar)
295
+ end
296
+
297
+ it "processes a Ruby 2.6 style period Sexp" do
298
+ sexp = s(:call,
299
+ s(:vcall, s(:@ident, "foo", s(1, 0))),
300
+ s(:@period, ".", s(1, 3)),
301
+ s(:@ident, "bar", s(1, 4)))
302
+ _(processor.process(sexp)).must_equal s(:call, s(:call, nil, :foo), :bar)
303
+ end
304
+
305
+ it "raises an error for an unknown call operator" do
306
+ sexp = s(:call,
307
+ s(:vcall, s(:@ident, "foo", s(1, 0))),
308
+ :'>.',
309
+ s(:@ident, "bar", s(1, 4)))
310
+ _(-> { processor.process(sexp) }).must_raise KeyError
311
+ end
288
312
  end
289
313
 
290
314
  describe "#extract_node_symbol" do
@@ -188,6 +188,9 @@ class Foo
188
188
  puts [foo, bar]
189
189
  end
190
190
 
191
+ def foobarbaz(**)
192
+ end
193
+
191
194
  # rescue
192
195
  def barfoo
193
196
  foo
@@ -279,3 +282,4 @@ end
279
282
 
280
283
  # Blocks
281
284
  foo do |bar, | end
285
+ foo do |bar, **| end
@@ -5,3 +5,5 @@
5
5
  100r
6
6
  0700
7
7
  0x100
8
+ 1+3i
9
+ 3.2-4.2i
@@ -16,7 +16,6 @@
16
16
  /2\302\275/
17
17
  "foo\u{101D1}bar"
18
18
 
19
-
20
19
  # Encoding
21
20
  "日本語"
22
21
  /日本語/
@@ -73,9 +73,8 @@ module MiniTest
73
73
  end
74
74
  end
75
75
 
76
- def assert_parsed_as(sexp, code, extra_compatible: false, with_line_numbers: false)
76
+ def assert_parsed_as(sexp, code, with_line_numbers: false)
77
77
  parser = RipperRubyParser::Parser.new
78
- parser.extra_compatible = extra_compatible
79
78
  result = parser.parse code
80
79
  if sexp.nil?
81
80
  assert_nil result
@@ -100,8 +99,13 @@ module MiniTest
100
99
  end
101
100
  end
102
101
 
103
- module Expectations
104
- infect_an_assertion :assert_parsed_as, :must_be_parsed_as
105
- infect_an_assertion :assert_parsed_as_before, :must_be_parsed_as_before, :unary
102
+ Expectation.class_eval do
103
+ def must_be_parsed_as(sexp, with_line_numbers: false)
104
+ ctx.assert_parsed_as(sexp, target, with_line_numbers: with_line_numbers)
105
+ end
106
+
107
+ def must_be_parsed_as_before(with_line_numbers: false)
108
+ ctx.assert_parsed_as_before(target, with_line_numbers: with_line_numbers)
109
+ end
106
110
  end
107
111
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripper_ruby_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matijs van Zuijlen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-03 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sexp_processor
@@ -106,6 +106,7 @@ files:
106
106
  - lib/ripper_ruby_parser/sexp_handlers/method_calls.rb
107
107
  - lib/ripper_ruby_parser/sexp_handlers/methods.rb
108
108
  - lib/ripper_ruby_parser/sexp_handlers/operators.rb
109
+ - lib/ripper_ruby_parser/sexp_handlers/string_literals.rb
109
110
  - lib/ripper_ruby_parser/sexp_processor.rb
110
111
  - lib/ripper_ruby_parser/syntax_error.rb
111
112
  - lib/ripper_ruby_parser/unescape.rb
@@ -127,6 +128,7 @@ files:
127
128
  - test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb
128
129
  - test/ripper_ruby_parser/sexp_handlers/methods_test.rb
129
130
  - test/ripper_ruby_parser/sexp_handlers/operators_test.rb
131
+ - test/ripper_ruby_parser/sexp_handlers/string_literals_test.rb
130
132
  - test/ripper_ruby_parser/sexp_processor_test.rb
131
133
  - test/ripper_ruby_parser/version_test.rb
132
134
  - test/samples/assignment.rb
@@ -160,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
162
  - !ruby/object:Gem::Version
161
163
  version: '0'
162
164
  requirements: []
163
- rubygems_version: 3.0.6
165
+ rubygems_version: 3.1.2
164
166
  signing_key:
165
167
  specification_version: 4
166
168
  summary: Parse with Ripper, produce sexps that are compatible with RubyParser.
@@ -182,6 +184,7 @@ test_files:
182
184
  - test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb
183
185
  - test/ripper_ruby_parser/sexp_handlers/methods_test.rb
184
186
  - test/ripper_ruby_parser/sexp_handlers/operators_test.rb
187
+ - test/ripper_ruby_parser/sexp_handlers/string_literals_test.rb
185
188
  - test/ripper_ruby_parser/sexp_processor_test.rb
186
189
  - test/ripper_ruby_parser/version_test.rb
187
190
  - test/samples/assignment.rb