rdoc 3.4 → 3.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

@@ -174,6 +174,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
174
174
  @scanner.exception_on_syntax_error = false
175
175
  @prev_seek = nil
176
176
 
177
+ @encoding = nil
178
+ @encoding = @options.encoding if Object.const_defined? :Encoding
179
+
177
180
  reset
178
181
  end
179
182
 
@@ -183,6 +186,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
183
186
  def collect_first_comment
184
187
  skip_tkspace
185
188
  comment = ''
189
+ comment.force_encoding @encoding if @encoding
186
190
  first_line = true
187
191
 
188
192
  tk = get_tk
@@ -449,6 +453,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
449
453
  # +comment+.
450
454
 
451
455
  def parse_attr(context, single, tk, comment)
456
+ offset = tk.seek
457
+ line_no = tk.line_no
458
+
452
459
  args = parse_symbol_arg 1
453
460
  if args.size > 0 then
454
461
  name = args[0]
@@ -464,6 +471,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
464
471
 
465
472
  att = RDoc::Attr.new get_tkread, name, rw, comment, single == SINGLE
466
473
  att.record_location @top_level
474
+ att.offset = offset
475
+ att.line = line_no
467
476
 
468
477
  read_documentation_modifiers att, RDoc::ATTR_MODIFIERS
469
478
 
@@ -480,6 +489,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
480
489
  # comment for each to +comment+.
481
490
 
482
491
  def parse_attr_accessor(context, single, tk, comment)
492
+ offset = tk.seek
493
+ line_no = tk.line_no
494
+
483
495
  args = parse_symbol_arg
484
496
  rw = "?"
485
497
 
@@ -498,6 +510,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
498
510
  for name in args
499
511
  att = RDoc::Attr.new get_tkread, name, rw, comment, single == SINGLE
500
512
  att.record_location @top_level
513
+ att.offset = offset
514
+ att.line = line_no
501
515
 
502
516
  context.add_attribute att
503
517
  @stats.add_attribute att
@@ -508,6 +522,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
508
522
  # Parses an +alias+ in +context+ with +comment+
509
523
 
510
524
  def parse_alias(context, single, tk, comment)
525
+ offset = tk.seek
526
+ line_no = tk.line_no
527
+
511
528
  skip_tkspace
512
529
 
513
530
  if TkLPAREN === peek_tk then
@@ -534,6 +551,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
534
551
  al = RDoc::Alias.new(get_tkread, old_name, new_name, comment,
535
552
  single == SINGLE)
536
553
  al.record_location @top_level
554
+ al.offset = offset
555
+ al.line = line_no
537
556
 
538
557
  read_documentation_modifiers al, RDoc::ATTR_MODIFIERS
539
558
  context.add_alias al if al.document_self
@@ -586,6 +605,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
586
605
  # Parses a class in +context+ with +comment+
587
606
 
588
607
  def parse_class(container, single, tk, comment)
608
+ offset = tk.seek
609
+ line_no = tk.line_no
610
+
589
611
  declaration_context = container
590
612
  container, name_t, given_name = get_class_or_module container
591
613
 
@@ -606,6 +628,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
606
628
 
607
629
  read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
608
630
  cls.record_location @top_level
631
+ cls.offset = offset
632
+ cls.line = line_no
633
+
609
634
  cls.comment = comment if cls.document_self
610
635
 
611
636
  @top_level.add_to_classes_or_modules cls
@@ -622,6 +647,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
622
647
  unless other then
623
648
  other = container.add_module RDoc::NormalModule, name
624
649
  other.record_location @top_level
650
+ other.offset = offset
651
+ other.line = line_no
652
+
625
653
  other.comment = comment
626
654
  end
627
655
 
@@ -639,7 +667,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
639
667
  read_documentation_modifiers other, RDoc::CLASS_MODIFIERS
640
668
  parse_statements(other, SINGLE)
641
669
  end
642
-
643
670
  else
644
671
  warn("Expected class name or '<<'. Got #{name_t.class}: #{name_t.text.inspect}")
645
672
  end
@@ -649,6 +676,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
649
676
  # Parses a constant in +context+ with +comment+
650
677
 
651
678
  def parse_constant(container, tk, comment)
679
+ offset = tk.seek
680
+ line_no = tk.line_no
681
+
652
682
  name = tk.name
653
683
  skip_tkspace false
654
684
 
@@ -698,7 +728,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
698
728
  container.find_module_named rhs_name
699
729
  end
700
730
 
701
- container.add_module_alias mod, name if mod
731
+ container.add_module_alias mod, name, @top_level if mod
702
732
  get_tk # TkNL
703
733
  break
704
734
  end
@@ -721,6 +751,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
721
751
 
722
752
  con = RDoc::Constant.new name, res, comment
723
753
  con.record_location @top_level
754
+ con.offset = offset
755
+ con.line = line_no
724
756
  read_documentation_modifiers con, RDoc::CONSTANT_MODIFIERS
725
757
 
726
758
  @stats.add_constant con
@@ -733,8 +765,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
733
765
  # :method: or :attr: directives in +comment+.
734
766
 
735
767
  def parse_comment(container, tk, comment)
736
- line_no = tk.line_no
737
768
  column = tk.char_no
769
+ offset = tk.seek
770
+ line_no = tk.line_no
738
771
 
739
772
  singleton = !!comment.sub!(/(^# +:?)(singleton-)(method:)/, '\1\3')
740
773
 
@@ -745,6 +778,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
745
778
  meth = RDoc::GhostMethod.new get_tkread, name
746
779
  meth.record_location @top_level
747
780
  meth.singleton = singleton
781
+ meth.offset = offset
782
+ meth.line = line_no
748
783
 
749
784
  meth.start_collecting_tokens
750
785
  indent = TkSPACE.new nil, 1, 1
@@ -777,6 +812,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
777
812
  # TODO authorize 'singleton-attr...'?
778
813
  att = RDoc::Attr.new get_tkread, name, rw, comment
779
814
  att.record_location @top_level
815
+ att.offset = offset
816
+ att.line = line_no
780
817
 
781
818
  container.add_attribute att
782
819
 
@@ -871,8 +908,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
871
908
  # Parses a meta-programmed method
872
909
 
873
910
  def parse_meta_method(container, single, tk, comment)
874
- line_no = tk.line_no
875
911
  column = tk.char_no
912
+ offset = tk.seek
913
+ line_no = tk.line_no
876
914
 
877
915
  start_collecting_tokens
878
916
  add_token tk
@@ -904,6 +942,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
904
942
 
905
943
  meth = RDoc::MetaMethod.new get_tkread, name
906
944
  meth.record_location @top_level
945
+ meth.offset = offset
946
+ meth.line = line_no
907
947
  meth.singleton = singleton
908
948
 
909
949
  remove_token_listener self
@@ -956,8 +996,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
956
996
  added_container = nil
957
997
  meth = nil
958
998
  name = nil
959
- line_no = tk.line_no
960
999
  column = tk.char_no
1000
+ offset = tk.seek
1001
+ line_no = tk.line_no
961
1002
 
962
1003
  start_collecting_tokens
963
1004
  add_token tk
@@ -1049,6 +1090,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
1049
1090
  end
1050
1091
 
1051
1092
  meth.record_location @top_level
1093
+ meth.offset = offset
1094
+ meth.line = line_no
1052
1095
 
1053
1096
  meth.start_collecting_tokens
1054
1097
  indent = TkSPACE.new nil, 1, 1
@@ -1221,6 +1264,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
1221
1264
 
1222
1265
  def parse_statements(container, single = NORMAL, current_method = nil,
1223
1266
  comment = '')
1267
+ comment.force_encoding @encoding if @encoding
1268
+
1224
1269
  nest = 1
1225
1270
  save_visibility = container.visibility
1226
1271
 
@@ -1244,6 +1289,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1244
1289
  comment.empty?
1245
1290
 
1246
1291
  comment = ''
1292
+ comment.force_encoding @encoding if @encoding
1247
1293
  end
1248
1294
 
1249
1295
  while TkCOMMENT === tk do
@@ -1383,7 +1429,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
1383
1429
  keep_comment = false
1384
1430
  end
1385
1431
 
1386
- comment = '' unless keep_comment
1432
+ unless keep_comment then
1433
+ comment = ''
1434
+ comment.force_encoding @encoding if @encoding
1435
+ end
1387
1436
 
1388
1437
  begin
1389
1438
  get_tkread
@@ -1596,8 +1645,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
1596
1645
  # Removes private comments from +comment+
1597
1646
 
1598
1647
  def remove_private_comments(comment)
1599
- comment.gsub!(/^#--\n.*?^#\+\+\n?/m, '')
1600
- comment.sub!(/^#--\n.*\n?/m, '')
1648
+ empty = ''
1649
+ empty.force_encoding comment.encoding if Object.const_defined? :Encoding
1650
+
1651
+ comment.gsub!(/^#--.*?^#\+\+\n?/m, empty)
1652
+ comment.sub!(/^#--.*/m, '')
1601
1653
  end
1602
1654
 
1603
1655
  ##
@@ -97,7 +97,8 @@ module RDoc::Text
97
97
  text = strip_hashes text
98
98
  text = expand_tabs text
99
99
  text = flush_left text
100
- strip_newlines text
100
+ text = strip_newlines text
101
+ text
101
102
  end
102
103
 
103
104
  ##
@@ -139,7 +140,11 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse
139
140
 
140
141
  def strip_hashes text
141
142
  return text if text =~ /^(?>\s*)[^\#]/
142
- text.gsub(/^\s*(#+)/) { $1.tr '#',' ' }.gsub(/^\s+$/, '')
143
+
144
+ empty = ''
145
+ empty.force_encoding text.encoding if Object.const_defined? :Encoding
146
+
147
+ text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty)
143
148
  end
144
149
 
145
150
  ##
@@ -34,6 +34,12 @@ method(a, b) { |c, d| ... }
34
34
  assert_equal call_seq, m.arglists
35
35
  end
36
36
 
37
+ def test_c_function
38
+ @c1_m.c_function = 'my_c1_m'
39
+
40
+ assert_equal 'my_c1_m', @c1_m.c_function
41
+ end
42
+
37
43
  def test_full_name
38
44
  assert_equal 'C1::m', @c1.method_list.first.full_name
39
45
  end
@@ -114,7 +114,7 @@ class TestRDocClassModule < XrefTestCase
114
114
  n1 = @xref_data.add_module RDoc::NormalClass, 'N1'
115
115
  n1_k2 = n1.add_module RDoc::NormalClass, 'N2'
116
116
 
117
- n1.add_module_alias n1_k2, 'A1'
117
+ n1.add_module_alias n1_k2, 'A1', @xref_data
118
118
 
119
119
  n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
120
120
  refute_nil n1_a1_c
@@ -138,7 +138,7 @@ class TestRDocClassModule < XrefTestCase
138
138
  n1 = @xref_data.add_module RDoc::NormalModule, 'N1'
139
139
  n1_n2 = n1.add_module RDoc::NormalModule, 'N2'
140
140
 
141
- n1.add_module_alias n1_n2, 'A1'
141
+ n1.add_module_alias n1_n2, 'A1', @xref_data
142
142
 
143
143
  n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
144
144
  refute_nil n1_a1_c
@@ -163,7 +163,7 @@ class TestRDocClassModule < XrefTestCase
163
163
  l1_l2 = l1.add_module RDoc::NormalModule, 'L2'
164
164
  o1 = @xref_data.add_module RDoc::NormalModule, 'O1'
165
165
 
166
- o1.add_module_alias l1_l2, 'A1'
166
+ o1.add_module_alias l1_l2, 'A1', @xref_data
167
167
 
168
168
  o1_a1_c = o1.constants.find { |c| c.name == 'A1' }
169
169
  refute_nil o1_a1_c
@@ -129,6 +129,12 @@ class TestRDocCodeObject < XrefTestCase
129
129
  assert_nil @co.instance_variable_get(:@full_name)
130
130
  end
131
131
 
132
+ def test_line
133
+ @c1_m.line = 5
134
+
135
+ assert_equal 5, @c1_m.line
136
+ end
137
+
132
138
  def test_metadata
133
139
  assert_empty @co.metadata
134
140
 
@@ -141,6 +147,12 @@ class TestRDocCodeObject < XrefTestCase
141
147
  assert_equal 'not_rdoc', @co.metadata['markup']
142
148
  end
143
149
 
150
+ def test_offset
151
+ @c1_m.offset = 5
152
+
153
+ assert_equal 5, @c1_m.offset
154
+ end
155
+
144
156
  def test_parent_file_name
145
157
  assert_equal '(unknown)', @co.parent_file_name
146
158
  assert_equal 'xref_data.rb', @c1.parent_file_name
@@ -174,9 +174,16 @@ class TestRDocContext < XrefTestCase
174
174
  end
175
175
 
176
176
  def test_add_module_alias
177
- c3_c4 = @c2.add_module_alias @c2_c3, 'C4'
177
+ tl = RDoc::TopLevel.new 'file.rb'
178
178
 
179
- assert_equal @c2.find_module_named('C4'), c3_c4
179
+ c3_c4 = @c2.add_module_alias @c2_c3, 'C4', tl
180
+
181
+ c4 = @c2.find_module_named('C4')
182
+
183
+ alias_constant = @c2.constants.first
184
+
185
+ assert_equal c4, c3_c4
186
+ assert_equal tl, alias_constant.file
180
187
  end
181
188
 
182
189
  def test_add_module_class
@@ -17,6 +17,7 @@ class TestRDocOptions < MiniTest::Unit::TestCase
17
17
  end
18
18
 
19
19
  def test_check_files
20
+ skip "assumes UNIX permition model" if /mswin|mingw/ =~ RUBY_PLATFORM
20
21
  out, err = capture_io do
21
22
  Dir.mktmpdir do |dir|
22
23
  Dir.chdir dir do
@@ -536,7 +536,7 @@ Init_Foo(void) {
536
536
 
537
537
  code = other_function.token_stream.first.text
538
538
 
539
- assert_equal "VALUE\nother_function() ", code
539
+ assert_equal "VALUE\nother_function() {\n}", code
540
540
  end
541
541
 
542
542
  def test_find_body_2
@@ -581,6 +581,41 @@ init_gi_repository (void)
581
581
 
582
582
  def test_find_body_define
583
583
  content = <<-EOF
584
+ #define something something_else
585
+
586
+ #define other_function rb_other_function
587
+
588
+ /*
589
+ * a comment for rb_other_function
590
+ */
591
+ VALUE
592
+ rb_other_function() {
593
+ }
594
+
595
+ void
596
+ Init_Foo(void) {
597
+ VALUE foo = rb_define_class("Foo", rb_cObject);
598
+
599
+ rb_define_method(foo, "my_method", other_function, 0);
600
+ }
601
+ EOF
602
+
603
+ klass = util_get_class content, 'foo'
604
+ other_function = klass.method_list.first
605
+
606
+ assert_equal 'my_method', other_function.name
607
+ assert_equal 'a comment for rb_other_function', other_function.comment
608
+ assert_equal '()', other_function.params
609
+ assert_equal 118, other_function.offset
610
+ assert_equal 8, other_function.line
611
+
612
+ code = other_function.token_stream.first.text
613
+
614
+ assert_equal "VALUE\nrb_other_function() {\n}", code
615
+ end
616
+
617
+ def test_find_body_define_comment
618
+ content = <<-EOF
584
619
  /*
585
620
  * a comment for other_function
586
621
  */
@@ -603,9 +638,10 @@ Init_Foo(void) {
603
638
  other_function = klass.method_list.first
604
639
 
605
640
  assert_equal 'my_method', other_function.name
606
- assert_equal "a comment for other_function",
607
- other_function.comment
641
+ assert_equal 'a comment for other_function', other_function.comment
608
642
  assert_equal '()', other_function.params
643
+ assert_equal 39, other_function.offset
644
+ assert_equal 4, other_function.line
609
645
 
610
646
  code = other_function.token_stream.first.text
611
647
 
@@ -749,19 +785,65 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
749
785
  assert_equal expected, comment
750
786
  end
751
787
 
752
- def test_handle_method
788
+ def test_handle_method_args_minus_1
753
789
  parser = util_parser "Document-method: Object#m\n blah */"
754
790
 
755
- parser.handle_method 'method', 'rb_cObject', 'm', 'rb_m', 2
791
+ parser.content = <<-BODY
792
+ VALUE
793
+ rb_other(VALUE obj) {
794
+ rb_funcall(obj, rb_intern("other"), 0);
795
+ return rb_str_new2("blah, blah, blah");
796
+ }
797
+
798
+ VALUE
799
+ rb_m(int argc, VALUE *argv, VALUE obj) {
800
+ VALUE o1, o2;
801
+ rb_scan_args(argc, argv, "1", &o1, &o2);
802
+ }
803
+ BODY
804
+
805
+ parser.handle_method 'method', 'rb_cObject', 'm', 'rb_m', -1
756
806
 
757
807
  m = @top_level.find_module_named('Object').method_list.first
758
808
 
759
809
  assert_equal 'm', m.name
760
- assert_equal '(p1, p2)', m.params
761
810
  assert_equal @top_level, m.file
811
+ assert_equal 115, m.offset
812
+ assert_equal 7, m.line
813
+
814
+ assert_equal '(p1)', m.params
762
815
  end
763
816
 
764
- def test_handle_method_args
817
+
818
+ def test_handle_method_args_0
819
+ parser = util_parser "Document-method: BasicObject#==\n blah */"
820
+
821
+ parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 0
822
+
823
+ bo = @top_level.find_module_named 'BasicObject'
824
+
825
+ assert_equal 1, bo.method_list.length
826
+
827
+ equals2 = bo.method_list.first
828
+
829
+ assert_equal '()', equals2.params
830
+ end
831
+
832
+ def test_handle_method_args_1
833
+ parser = util_parser "Document-method: BasicObject#==\n blah */"
834
+
835
+ parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 1
836
+
837
+ bo = @top_level.find_module_named 'BasicObject'
838
+
839
+ assert_equal 1, bo.method_list.length
840
+
841
+ equals2 = bo.method_list.first
842
+
843
+ assert_equal '(p1)', equals2.params
844
+ end
845
+
846
+ def test_handle_method_args_2
765
847
  parser = util_parser "Document-method: BasicObject#==\n blah */"
766
848
 
767
849
  parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 2
@@ -775,6 +857,22 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
775
857
  assert_equal '(p1, p2)', equals2.params
776
858
  end
777
859
 
860
+ # test_handle_args_minus_1 handled by test_handle_method
861
+
862
+ def test_handle_method_args_minus_2
863
+ parser = util_parser "Document-method: BasicObject#==\n blah */"
864
+
865
+ parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', -2
866
+
867
+ bo = @top_level.find_module_named 'BasicObject'
868
+
869
+ assert_equal 1, bo.method_list.length
870
+
871
+ equals2 = bo.method_list.first
872
+
873
+ assert_equal '(*args)', equals2.params
874
+ end
875
+
778
876
  def test_handle_method_initialize
779
877
  parser = util_parser "Document-method: BasicObject::new\n blah */"
780
878
 
@@ -791,16 +889,6 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
791
889
  assert_equal :public, new.visibility
792
890
  end
793
891
 
794
- def test_handle_method_star_args
795
- parser = util_parser "Document-method: Object#m\n blah */"
796
-
797
- parser.handle_method 'method', 'rb_cObject', 'm', 'rb_m', -1
798
-
799
- m = @top_level.find_module_named('Object').method_list.first
800
-
801
- assert_equal '(*args)', m.params
802
- end
803
-
804
892
  def test_look_for_directives_in
805
893
  parser = util_parser ''
806
894
 
@@ -837,6 +925,7 @@ Init_IO(void) {
837
925
  read_method = klass.method_list.first
838
926
  assert_equal "read", read_method.name
839
927
  assert_equal "Method Comment! ", read_method.comment
928
+ assert_equal "rb_io_s_read", read_method.c_function
840
929
  assert read_method.singleton
841
930
  end
842
931
 
@@ -927,6 +1016,65 @@ Init_IO(void) {
927
1016
  assert read_method.singleton
928
1017
  end
929
1018
 
1019
+ def test_rb_scan_args
1020
+ parser = util_parser ''
1021
+
1022
+ assert_equal '(p1)',
1023
+ parser.rb_scan_args('rb_scan_args(a, b, "1",)')
1024
+ assert_equal '(p1, p2)',
1025
+ parser.rb_scan_args('rb_scan_args(a, b, "2",)')
1026
+
1027
+ assert_equal '(p1 = v1)',
1028
+ parser.rb_scan_args('rb_scan_args(a, b, "01",)')
1029
+ assert_equal '(p1 = v1, p2 = v2)',
1030
+ parser.rb_scan_args('rb_scan_args(a, b, "02",)')
1031
+
1032
+ assert_equal '(p1, p2 = v2)',
1033
+ parser.rb_scan_args('rb_scan_args(a, b, "11",)')
1034
+
1035
+ assert_equal '(p1, *args)',
1036
+ parser.rb_scan_args('rb_scan_args(a, b, "1*",)')
1037
+ assert_equal '(p1, p2 = {})',
1038
+ parser.rb_scan_args('rb_scan_args(a, b, "1:",)')
1039
+ assert_equal '(p1, &block)',
1040
+ parser.rb_scan_args('rb_scan_args(a, b, "1&",)')
1041
+
1042
+ assert_equal '(p1, p2)',
1043
+ parser.rb_scan_args('rb_scan_args(a, b, "101",)')
1044
+
1045
+ assert_equal '(p1, p2 = v2, p3)',
1046
+ parser.rb_scan_args('rb_scan_args(a, b, "111",)')
1047
+
1048
+ assert_equal '(p1, *args, p3)',
1049
+ parser.rb_scan_args('rb_scan_args(a, b, "1*1",)')
1050
+
1051
+ assert_equal '(p1, p2 = v2, *args)',
1052
+ parser.rb_scan_args('rb_scan_args(a, b, "11*",)')
1053
+ assert_equal '(p1, p2 = v2, p3 = {})',
1054
+ parser.rb_scan_args('rb_scan_args(a, b, "11:",)')
1055
+ assert_equal '(p1, p2 = v2, &block)',
1056
+ parser.rb_scan_args('rb_scan_args(a, b, "11&",)')
1057
+
1058
+ assert_equal '(p1, p2 = v2, *args, p4, p5 = {}, &block)',
1059
+ parser.rb_scan_args('rb_scan_args(a, b, "11*1:&",)')
1060
+
1061
+ # The following aren't valid according to spec but are according to the
1062
+ # implementation.
1063
+ assert_equal '(*args)',
1064
+ parser.rb_scan_args('rb_scan_args(a, b, "*",)')
1065
+ assert_equal '(p1 = {})',
1066
+ parser.rb_scan_args('rb_scan_args(a, b, ":",)')
1067
+ assert_equal '(&block)',
1068
+ parser.rb_scan_args('rb_scan_args(a, b, "&",)')
1069
+
1070
+ assert_equal '(*args, p2 = {})',
1071
+ parser.rb_scan_args('rb_scan_args(a, b, "*:",)')
1072
+ assert_equal '(p1 = {}, &block)',
1073
+ parser.rb_scan_args('rb_scan_args(a, b, ":&",)')
1074
+ assert_equal '(*args, p2 = {}, &block)',
1075
+ parser.rb_scan_args('rb_scan_args(a, b, "*:&",)')
1076
+ end
1077
+
930
1078
  def util_get_class(content, name)
931
1079
  @parser = util_parser content
932
1080
  @parser.scan