ripper_ruby_parser 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ # Samples of assignment
2
+ foo[bar] = baz
3
+ foo[bar] += baz
4
+ foo[bar] ||= foo bar
5
+ foo[bar] ||= foo(bar)
6
+ foo[bar] ||= baz.qux quuz
7
+ foo[bar] ||= baz.qux(quuz)
8
+
9
+ # Destructuring assignments
10
+ foo, bar = baz
11
+ (foo, bar) = baz
12
+ ((foo, bar)) = baz
13
+ (((foo, bar))) = baz
14
+ foo, (bar, baz) = qux
15
+ foo, ((bar, baz)) = qux
16
+ foo, (((bar, baz))) = qux
17
+ foo, (bar, (baz, qux)) = quuz
@@ -129,6 +129,42 @@ class Foo
129
129
  baz
130
130
  end
131
131
  end
132
+
133
+ case foo
134
+ when bar
135
+ begin
136
+ baz
137
+ qux
138
+ end
139
+ end
140
+
141
+ case foo
142
+ when bar
143
+ begin
144
+ baz
145
+ qux
146
+ end
147
+ quuz
148
+ end
149
+
150
+ case foo
151
+ when bar
152
+ else
153
+ begin
154
+ baz
155
+ qux
156
+ end
157
+ end
158
+
159
+ case foo
160
+ when bar
161
+ else
162
+ begin
163
+ baz
164
+ qux
165
+ end
166
+ quuz
167
+ end
132
168
  end
133
169
 
134
170
  # Using splat and double-splat args
@@ -163,6 +199,13 @@ class Foo
163
199
  puts err
164
200
  end
165
201
 
202
+ # begin/rescue with multiple assignment
203
+ foo, bar = begin
204
+ baz
205
+ rescue qux
206
+ quuz
207
+ end
208
+
166
209
  # alias
167
210
  alias foo bar
168
211
  alias :foo bar
@@ -198,4 +241,38 @@ class Foo
198
241
  # definitions.
199
242
  def foo(bar = ($baz = qux))
200
243
  end
244
+
245
+ # Argument destructuring
246
+ def foo((bar, baz))
247
+ end
248
+
249
+ def foo((bar, baz), (qux, quuz))
250
+ end
251
+
252
+ def foo((bar, *qux))
253
+ end
254
+
255
+ def foo((bar, (baz, qux)))
256
+ end
257
+
258
+ def foo((bar, (baz, *qux)))
259
+ end
260
+
261
+ def self.foo((bar, baz))
262
+ end
263
+
264
+ def self.foo((bar, baz), (qux, quuz))
265
+ end
266
+
267
+ def self.foo((bar, *qux))
268
+ end
269
+
270
+ def self.foo((bar, (baz, qux)))
271
+ end
272
+
273
+ def self.foo((bar, (baz, *qux)))
274
+ end
201
275
  end
276
+
277
+ # Special symbols
278
+ [:`, :|, :*, :&, :%, :'^', :-@, :+@, :'~@']
@@ -6,6 +6,7 @@
6
6
  %w(foo\nbar baz)
7
7
 
8
8
  "foo\u273bbar"
9
+ "foo\a\b\e\f\r\s\t\vbar\nbaz"
9
10
  "\0"
10
11
  "foo#{bar}\0"
11
12
  "foo#{bar}baz\0"
@@ -14,6 +15,7 @@
14
15
  %W(2\302\275)
15
16
  /2\302\275/
16
17
 
18
+
17
19
  # Encoding
18
20
  "日本語"
19
21
  /日本語/
@@ -37,6 +39,16 @@ FOO
37
39
  \n
38
40
  FOO
39
41
 
42
+ # Escape sequences in heredocs, in particular carriage returns
43
+ #
44
+ <<FOO
45
+ foo\rbar\tbaz\r
46
+ FOO
47
+
48
+ <<'FOO'
49
+ foo\rbar\tbaz\r
50
+ FOO
51
+
40
52
  # Line continuation
41
53
  "foo\
42
54
  bar"
@@ -57,6 +69,18 @@ foo4\
57
69
  bar
58
70
  EOS
59
71
 
72
+ <<EOS
73
+ #{bar}
74
+ baz \
75
+ qux
76
+ EOS
77
+
78
+ <<-EOS
79
+ #{bar}
80
+ baz \
81
+ qux
82
+ EOS
83
+
60
84
  %Q[foo5\
61
85
  bar]
62
86
 
@@ -108,3 +132,9 @@ eval(<<FOO, __FILE__, __LINE__)
108
132
  bar
109
133
  baz
110
134
  FOO
135
+
136
+ # Interpolation
137
+ "foo#{bar}"
138
+ "foo#{"bar#{baz}"}"
139
+ "foo#{"bar#{"baz#{qux}"}"}"
140
+ "foo#{"bar#{baz}"}foo#{"bar#{baz}"}"
@@ -61,7 +61,7 @@ module MiniTest
61
61
  end
62
62
 
63
63
  def assert_parsed_as_before(code)
64
- oldparser = RubyParser.new
64
+ oldparser = RubyParser.for_current_ruby
65
65
  newparser = RipperRubyParser::Parser.new
66
66
  newparser.extra_compatible = true
67
67
  expected = oldparser.parse code.dup
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.5.1
4
+ version: 1.6.0
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-03-21 00:00:00.000000000 Z
11
+ date: 2019-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sexp_processor
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.12.0
61
+ version: 3.13.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.12.0
68
+ version: 3.13.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -129,6 +129,7 @@ files:
129
129
  - test/ripper_ruby_parser/sexp_handlers/operators_test.rb
130
130
  - test/ripper_ruby_parser/sexp_processor_test.rb
131
131
  - test/ripper_ruby_parser/version_test.rb
132
+ - test/samples/assignment.rb
132
133
  - test/samples/comments.rb
133
134
  - test/samples/conditionals.rb
134
135
  - test/samples/loops.rb
@@ -182,6 +183,7 @@ test_files:
182
183
  - test/ripper_ruby_parser/sexp_handlers/operators_test.rb
183
184
  - test/ripper_ruby_parser/sexp_processor_test.rb
184
185
  - test/ripper_ruby_parser/version_test.rb
186
+ - test/samples/assignment.rb
185
187
  - test/samples/comments.rb
186
188
  - test/samples/conditionals.rb
187
189
  - test/samples/loops.rb