ruby_parser 3.9.0 → 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1153,6 +1153,47 @@ class TestRubyLexer < Minitest::Test
1153
1153
  :tNL, nil, :expr_beg)
1154
1154
  end
1155
1155
 
1156
+ def test_yylex_heredoc_double_squiggly
1157
+ setup_lexer_class Ruby23Parser
1158
+
1159
+ assert_lex3("a = <<~\"EOF\"\n blah blah\n EOF\n\n",
1160
+ nil,
1161
+ :tIDENTIFIER, "a", :expr_cmdarg,
1162
+ :tEQL, "=", :expr_beg,
1163
+ :tSTRING_BEG, "\"", :expr_beg,
1164
+ :tSTRING_CONTENT, "blah blah\n", :expr_beg,
1165
+ :tSTRING_END, "EOF", :expr_end,
1166
+ :tNL, nil, :expr_beg)
1167
+ end
1168
+
1169
+ # mri handles tabs in a pretty specific way:
1170
+ # https://github.com/ruby/ruby/blob/trunk/parse.y#L5925
1171
+ def test_yylex_heredoc_double_squiggly_with_tab_indentation_remaining
1172
+ setup_lexer_class Ruby23Parser
1173
+
1174
+ assert_lex3("a = <<~\"EOF\"\n blah blah\n \tblah blah\n EOF\n\n",
1175
+ nil,
1176
+ :tIDENTIFIER, "a", :expr_cmdarg,
1177
+ :tEQL, "=", :expr_beg,
1178
+ :tSTRING_BEG, "\"", :expr_beg,
1179
+ :tSTRING_CONTENT, "blah blah\n\tblah blah\n", :expr_beg,
1180
+ :tSTRING_END, "EOF", :expr_end,
1181
+ :tNL, nil, :expr_beg)
1182
+ end
1183
+
1184
+ def test_yylex_heredoc_double_squiggly_with_tab_indentation_removed
1185
+ setup_lexer_class Ruby23Parser
1186
+
1187
+ assert_lex3("a = <<~\"EOF\"\n blah blah\n\t blah blah\n EOF\n\n",
1188
+ nil,
1189
+ :tIDENTIFIER, "a", :expr_cmdarg,
1190
+ :tEQL, "=", :expr_beg,
1191
+ :tSTRING_BEG, "\"", :expr_beg,
1192
+ :tSTRING_CONTENT, "blah blah\n blah blah\n", :expr_beg,
1193
+ :tSTRING_END, "EOF", :expr_end,
1194
+ :tNL, nil, :expr_beg)
1195
+ end
1196
+
1156
1197
  def test_yylex_heredoc_double_eos
1157
1198
  refute_lex("a = <<\"EOF\"\nblah",
1158
1199
  :tIDENTIFIER, "a",
@@ -1223,6 +1264,19 @@ class TestRubyLexer < Minitest::Test
1223
1264
  :tNL, nil, :expr_beg)
1224
1265
  end
1225
1266
 
1267
+ def test_yylex_heredoc_none_squiggly
1268
+ setup_lexer_class Ruby23Parser
1269
+
1270
+ assert_lex3("a = <<~EOF\n blah\n blah\n EOF\n",
1271
+ nil,
1272
+ :tIDENTIFIER, "a", :expr_cmdarg,
1273
+ :tEQL, "=", :expr_beg,
1274
+ :tSTRING_BEG, "\"", :expr_beg,
1275
+ :tSTRING_CONTENT, "blah\nblah\n", :expr_beg,
1276
+ :tSTRING_END, "EOF", :expr_end,
1277
+ :tNL, nil, :expr_beg)
1278
+ end
1279
+
1226
1280
  def test_yylex_heredoc_single
1227
1281
  assert_lex3("a = <<'EOF'\n blah blah\nEOF\n\n",
1228
1282
  nil,
@@ -1273,6 +1327,19 @@ class TestRubyLexer < Minitest::Test
1273
1327
  :tNL, nil, :expr_beg)
1274
1328
  end
1275
1329
 
1330
+ def test_yylex_heredoc_single_squiggly
1331
+ setup_lexer_class Ruby23Parser
1332
+
1333
+ assert_lex3("a = <<~'EOF'\n blah blah\n EOF\n\n",
1334
+ nil,
1335
+ :tIDENTIFIER, "a", :expr_cmdarg,
1336
+ :tEQL, "=", :expr_beg,
1337
+ :tSTRING_BEG, "\"", :expr_beg,
1338
+ :tSTRING_CONTENT, "blah blah\n", :expr_beg,
1339
+ :tSTRING_END, "EOF", :expr_end,
1340
+ :tNL, nil, :expr_beg)
1341
+ end
1342
+
1276
1343
  def test_yylex_identifier
1277
1344
  assert_lex3("identifier",
1278
1345
  nil,
@@ -571,6 +571,14 @@ module TestRubyParserShared
571
571
  assert_parse rb, pt
572
572
  end
573
573
 
574
+ def test_str_newline_hash_line_number
575
+ rb = "\"\\n\\n\\n\\n#\"\n1"
576
+ pt = s(:block, s(:str, "\n\n\n\n#").line(1),
577
+ s(:lit, 1).line(2))
578
+
579
+ assert_parse rb, pt
580
+ end
581
+
574
582
  def after_process_hook klass, node, data, input_name, output_name
575
583
  assert_equal 1, @result.line, "should have proper line number"
576
584
  end
@@ -811,7 +819,6 @@ module TestRubyParserShared
811
819
  end
812
820
 
813
821
  def test_parse_line_rescue
814
- skip "not yet"
815
822
  rb = "begin\n a\n rescue\n b\n rescue\n c\n end\n"
816
823
  pt = s(:rescue,
817
824
  s(:call, nil, :a).line(2),
@@ -1709,6 +1716,16 @@ module TestRubyParserShared
1709
1716
  assert_parse rb, pt
1710
1717
  end
1711
1718
 
1719
+ def test_defs_as_arg_with_do_block_inside
1720
+ rb = "p def self.b; x.y do; end; end"
1721
+ pt = s(:call,
1722
+ nil,
1723
+ :p,
1724
+ s(:defs, s(:self), :b, s(:args),
1725
+ s(:iter, s(:call, s(:call, nil, :x), :y), 0)))
1726
+
1727
+ assert_parse rb, pt
1728
+ end
1712
1729
  end
1713
1730
 
1714
1731
  module TestRubyParserShared19Plus
@@ -3239,6 +3256,20 @@ module TestRubyParserShared20Plus
3239
3256
 
3240
3257
  assert_parse rb, pt
3241
3258
  end
3259
+
3260
+ def test_bug_249
3261
+ rb = "mount (Class.new do\ndef initialize\nend\n end).new, :at => 'endpoint'"
3262
+ pt = s(:call, nil, :mount,
3263
+ s(:call,
3264
+ s(:iter,
3265
+ s(:call, s(:const, :Class), :new),
3266
+ 0,
3267
+ s(:defn, :initialize, s(:args), s(:nil))),
3268
+ :new),
3269
+ s(:hash, s(:lit, :at), s(:str, "endpoint")))
3270
+
3271
+ assert_parse rb, pt
3272
+ end
3242
3273
  end
3243
3274
 
3244
3275
  module TestRubyParserShared22Plus
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -30,7 +30,7 @@ cert_chain:
30
30
  E4oJcnPkJAr0rw504JGtlZtONZQblwmRJOIdXzolaE3NRGUzGVOUSptZppAKiavY
31
31
  fO6tdKQc/5RfA8oQEkg8hrxA5PQSz4TOFJGLpFvIapEk6tMruQ0bHgkhr9auXg==
32
32
  -----END CERTIFICATE-----
33
- date: 2017-04-14 00:00:00.000000000 Z
33
+ date: 2017-07-17 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: sexp_processor
@@ -38,14 +38,14 @@ dependencies:
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '4.1'
41
+ version: '4.9'
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '4.1'
48
+ version: '4.9'
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rake
51
51
  requirement: !ruby/object:Gem::Requirement
@@ -66,14 +66,14 @@ dependencies:
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '2.1'
69
+ version: '2.5'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '2.1'
76
+ version: '2.5'
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: rdoc
79
79
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file