@@ -74,7 +74,7 @@ class C; end
7474
7575 comment = parser . collect_first_comment
7676
77- assert_equal RDoc ::Comment . new ( "first \n \n " , @top_level ) , comment
77+ assert_equal RDoc ::Comment . new ( "=begin \n first \n =end \n \n " , @top_level ) , comment
7878 end
7979
8080 def test_get_class_or_module
@@ -2499,6 +2499,35 @@ def blah()
24992499 assert_equal markup_code , expected
25002500 end
25012501
2502+ def test_parse_statements_postfix_if_after_heredocbeg
2503+ @filename = 'file.rb'
2504+ util_parser <<RUBY
2505+ class Foo
2506+ def blah()
2507+ <<~EOM if true
2508+ EOM
2509+ end
2510+ end
2511+ RUBY
2512+
2513+ expected = <<EXPTECTED
2514+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">blah</span>()
2515+ <span class="ruby-identifier"><<~EOM</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">true</span>
2516+ <span class="ruby-value"></span><span class="ruby-identifier"> EOM</span>
2517+ <span class="ruby-keyword">end</span>
2518+ EXPTECTED
2519+ expected = expected . rstrip
2520+
2521+ @parser . scan
2522+
2523+ foo = @top_level . classes . first
2524+ assert_equal 'Foo' , foo . full_name
2525+
2526+ blah = foo . method_list . first
2527+ markup_code = blah . markup_code . sub ( /^.*\n / , '' )
2528+ assert_equal markup_code , expected
2529+ end
2530+
25022531 def test_parse_statements_method_oneliner_with_regexp
25032532 util_parser <<RUBY
25042533class Foo
@@ -2521,6 +2550,40 @@ def blah() /bar/ end
25212550 assert_equal expected , markup_code
25222551 end
25232552
2553+ def test_parse_statements_embdoc_in_document
2554+ @filename = 'file.rb'
2555+ util_parser <<RUBY
2556+ class Foo
2557+ # doc
2558+ #
2559+ # =begin
2560+ # test embdoc
2561+ # =end
2562+ #
2563+ def blah
2564+ end
2565+ end
2566+ RUBY
2567+
2568+ expected = <<EXPTECTED
2569+ <p>doc
2570+
2571+ <pre class="ruby"><span class="ruby-comment">=begin
2572+ test embdoc
2573+ =end</span>
2574+ </pre>
2575+ EXPTECTED
2576+
2577+ @parser . scan
2578+
2579+ foo = @top_level . classes . first
2580+ assert_equal 'Foo' , foo . full_name
2581+
2582+ blah = foo . method_list . first
2583+ markup_comment = blah . search_record [ 6 ]
2584+ assert_equal markup_comment , expected
2585+ end
2586+
25242587 def test_parse_require_dynamic_string
25252588 content = <<-RUBY
25262589prefix = 'path'
@@ -2995,11 +3058,11 @@ def m() end
29953058
29963059 foo = @top_level . classes . first
29973060
2998- assert_equal 'Foo comment' , foo . comment . text
3061+ assert_equal "=begin rdoc \n Foo comment\n =end" , foo . comment . text
29993062
30003063 m = foo . method_list . first
30013064
3002- assert_equal 'm comment' , m . comment . text
3065+ assert_equal "=begin \n m comment\n =end" , m . comment . text
30033066 end
30043067
30053068 def test_scan_block_comment_nested # Issue #41
@@ -3021,7 +3084,7 @@ class Bar
30213084 foo = @top_level . modules . first
30223085
30233086 assert_equal 'Foo' , foo . full_name
3024- assert_equal 'findmeindoc' , foo . comment . text
3087+ assert_equal "=begin rdoc \n findmeindoc \n =end" , foo . comment . text
30253088
30263089 bar = foo . classes . first
30273090
@@ -3068,12 +3131,12 @@ def lauren
30683131
30693132 foo = @top_level . classes . first
30703133
3071- assert_equal "= DESCRIPTION\n \n This is a simple test class\n \n = RUMPUS\n \n Is a silly word" ,
3134+ assert_equal "=begin rdoc \n \n = DESCRIPTION\n \n This is a simple test class\n \n = RUMPUS\n \n Is a silly word\n \n =end " ,
30723135 foo . comment . text
30733136
30743137 m = foo . method_list . first
30753138
3076- assert_equal 'A nice girl' , m . comment . text
3139+ assert_equal "=begin rdoc \n A nice girl\n =end" , m . comment . text
30773140 end
30783141
30793142 def test_scan_class_nested_nodoc
0 commit comments