diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-27 10:45:24 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-27 10:45:24 +0000 |
commit | 55518710865bd7258422807524403c91347519a2 (patch) | |
tree | 4146c423ab0c55ed35d9d860e64d7e3a7e2a9efb /test | |
parent | 2d9f20e1cfdc7532a8acef4da9b8b7a788c4e99a (diff) |
Merge rdoc-6.0.0.beta4 from upstream.
It version applied `frozen_string_literal: true`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
80 files changed, 309 insertions, 171 deletions
diff --git a/test/rdoc/test_rdoc_alias.rb b/test/rdoc/test_rdoc_alias.rb index fa0ab0f366..89ae2d5a56 100644 --- a/test/rdoc/test_rdoc_alias.rb +++ b/test/rdoc/test_rdoc_alias.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocAlias < XrefTestCase diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb index 20d041bd7e..55793255ba 100644 --- a/test/rdoc/test_rdoc_any_method.rb +++ b/test/rdoc/test_rdoc_any_method.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocAnyMethod < XrefTestCase diff --git a/test/rdoc/test_rdoc_attr.rb b/test/rdoc/test_rdoc_attr.rb index e4062d1807..ae702ac702 100644 --- a/test/rdoc/test_rdoc_attr.rb +++ b/test/rdoc/test_rdoc_attr.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocAttr < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb index 7cbbcbcc52..273a21120f 100644 --- a/test/rdoc/test_rdoc_class_module.rb +++ b/test/rdoc/test_rdoc_class_module.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocClassModule < XrefTestCase @@ -42,7 +42,8 @@ class TestRDocClassModule < XrefTestCase cm.add_comment '# comment 1', tl1 cm.add_comment '# comment 2', tl1 - assert_equal [['comment 2', tl1]], cm.comment_location + assert_equal [['comment 1', tl1], + ['comment 2', tl1]], cm.comment_location end def test_add_comment_stopdoc diff --git a/test/rdoc/test_rdoc_code_object.rb b/test/rdoc/test_rdoc_code_object.rb index be4ca268e4..d189ac1c4b 100644 --- a/test/rdoc/test_rdoc_code_object.rb +++ b/test/rdoc/test_rdoc_code_object.rb @@ -1,5 +1,5 @@ # coding: US-ASCII -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ @@ -53,7 +53,7 @@ class TestRDocCodeObject < XrefTestCase refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check' input = 'text' - input.force_encoding Encoding::UTF_8 + input = RDoc::Encoding.change_encoding input, Encoding::UTF_8 @co.comment = input @@ -65,7 +65,7 @@ class TestRDocCodeObject < XrefTestCase refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check' input = '' - input.force_encoding Encoding::UTF_8 + input = RDoc::Encoding.change_encoding input, Encoding::UTF_8 @co.comment = input diff --git a/test/rdoc/test_rdoc_comment.rb b/test/rdoc/test_rdoc_comment.rb index 3b0927212f..567daae51c 100644 --- a/test/rdoc/test_rdoc_comment.rb +++ b/test/rdoc/test_rdoc_comment.rb @@ -1,5 +1,5 @@ # coding: us-ascii -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' @@ -207,7 +207,7 @@ lines, one line per element. Lines are assumed to be separated by _sep_. end def test_force_encoding - @comment.force_encoding Encoding::UTF_8 + @comment = RDoc::Encoding.change_encoding @comment, Encoding::UTF_8 assert_equal Encoding::UTF_8, @comment.text.encoding end @@ -347,7 +347,7 @@ lines, one line per element. Lines are assumed to be separated by _sep_. # this is private EOS - comment.force_encoding Encoding::IBM437 + comment = RDoc::Encoding.change_encoding comment, Encoding::IBM437 comment.remove_private @@ -471,7 +471,7 @@ lines, one line per element. Lines are assumed to be separated by _sep_. # This is text again. EOS - comment.force_encoding Encoding::IBM437 + comment = RDoc::Encoding.change_encoding comment, Encoding::IBM437 comment.remove_private @@ -486,7 +486,7 @@ lines, one line per element. Lines are assumed to be separated by _sep_. # This is text again. EOS - comment.force_encoding Encoding::IBM437 + comment = RDoc::Encoding.change_encoding comment, Encoding::IBM437 comment.remove_private diff --git a/test/rdoc/test_rdoc_constant.rb b/test/rdoc/test_rdoc_constant.rb index a03ab97a7d..e715131579 100644 --- a/test/rdoc/test_rdoc_constant.rb +++ b/test/rdoc/test_rdoc_constant.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocConstant < XrefTestCase diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb index ceac14ac90..a7d6a58716 100644 --- a/test/rdoc/test_rdoc_context.rb +++ b/test/rdoc/test_rdoc_context.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocContext < XrefTestCase diff --git a/test/rdoc/test_rdoc_context_section.rb b/test/rdoc/test_rdoc_context_section.rb index b008c60c57..ff88b9b66a 100644 --- a/test/rdoc/test_rdoc_context_section.rb +++ b/test/rdoc/test_rdoc_context_section.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocContextSection < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_cross_reference.rb b/test/rdoc/test_rdoc_cross_reference.rb index c39d6ad356..a294553704 100644 --- a/test/rdoc/test_rdoc_cross_reference.rb +++ b/test/rdoc/test_rdoc_cross_reference.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocCrossReference < XrefTestCase diff --git a/test/rdoc/test_rdoc_encoding.rb b/test/rdoc/test_rdoc_encoding.rb index 915f3ce5ec..9d9ded4bbd 100644 --- a/test/rdoc/test_rdoc_encoding.rb +++ b/test/rdoc/test_rdoc_encoding.rb @@ -1,5 +1,5 @@ # coding: US-ASCII -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' @@ -37,7 +37,7 @@ class TestRDocEncoding < RDoc::TestCase def test_class_read_file_encoding_convert content = "" - content.encode! 'ISO-8859-1' + content = RDoc::Encoding.change_encoding content, 'ISO-8859-1' content << "# coding: ISO-8859-1\nhi \xE9verybody" @tempfile.write content @@ -65,7 +65,7 @@ class TestRDocEncoding < RDoc::TestCase def test_class_read_file_encoding_fancy expected = "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody" - expected.encode! Encoding::UTF_8 + exptected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8 @tempfile.write expected @tempfile.flush @@ -125,7 +125,7 @@ class TestRDocEncoding < RDoc::TestCase contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8 expected = ":\xe3\x82\xb3\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x89:" - expected.force_encoding Encoding::UTF_8 + expected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8 assert_equal expected, contents assert_equal Encoding::UTF_8, contents.encoding @@ -133,26 +133,24 @@ class TestRDocEncoding < RDoc::TestCase def test_class_set_encoding s = "# coding: UTF-8\n" - RDoc::Encoding.set_encoding s + s = RDoc::Encoding.set_encoding s # sanity check for 1.8 assert_equal Encoding::UTF_8, s.encoding s = "#!/bin/ruby\n# coding: UTF-8\n" - RDoc::Encoding.set_encoding s + s = RDoc::Encoding.set_encoding s assert_equal Encoding::UTF_8, s.encoding s = "<?xml version='1.0' encoding='UTF-8'?>\n" - expected = s.encoding - RDoc::Encoding.set_encoding s + s = RDoc::Encoding.set_encoding s assert_equal Encoding::UTF_8, s.encoding s = "<?xml version='1.0' encoding=\"UTF-8\"?>\n" - expected = s.encoding - RDoc::Encoding.set_encoding s + s = RDoc::Encoding.set_encoding s assert_equal Encoding::UTF_8, s.encoding end @@ -160,13 +158,13 @@ class TestRDocEncoding < RDoc::TestCase def test_class_set_encoding_strip s = "# coding: UTF-8\n# more comments" - RDoc::Encoding.set_encoding s + s = RDoc::Encoding.set_encoding s assert_equal "# more comments", s s = "#!/bin/ruby\n# coding: UTF-8\n# more comments" - RDoc::Encoding.set_encoding s + s = RDoc::Encoding.set_encoding s assert_equal "#!/bin/ruby\n# more comments", s end @@ -174,29 +172,29 @@ class TestRDocEncoding < RDoc::TestCase def test_class_set_encoding_bad s = "" expected = s.encoding - RDoc::Encoding.set_encoding s + s = RDoc::Encoding.set_encoding s assert_equal expected, s.encoding s = "# vim:set fileencoding=utf-8:\n" expected = s.encoding - RDoc::Encoding.set_encoding s + s = RDoc::Encoding.set_encoding s assert_equal expected, s.encoding s = "# vim:set fileencoding=utf-8:\n" expected = s.encoding - RDoc::Encoding.set_encoding s + s = RDoc::Encoding.set_encoding s assert_equal expected, s.encoding assert_raises ArgumentError do - RDoc::Encoding.set_encoding "# -*- encoding: undecided -*-\n" + s = RDoc::Encoding.set_encoding "# -*- encoding: undecided -*-\n" end end def test_skip_frozen_string_literal - expected = "# frozen_string_literal: false\nhi everybody" + expected = "# frozen_string_literal: true\nhi everybody" @tempfile.write expected @tempfile.flush @@ -218,7 +216,7 @@ class TestRDocEncoding < RDoc::TestCase end def test_skip_frozen_string_literal_before_coding - expected = "# frozen_string_literal: false\n# coding: utf-8\nhi everybody" + expected = "# frozen_string_literal: true\n# coding: utf-8\nhi everybody" @tempfile.write expected @tempfile.flush diff --git a/test/rdoc/test_rdoc_extend.rb b/test/rdoc/test_rdoc_extend.rb index bc50a657ac..f4c8425864 100644 --- a/test/rdoc/test_rdoc_extend.rb +++ b/test/rdoc/test_rdoc_extend.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocExtend < XrefTestCase diff --git a/test/rdoc/test_rdoc_generator_darkfish.rb b/test/rdoc/test_rdoc_generator_darkfish.rb index bbe351c0f6..c004bb271e 100644 --- a/test/rdoc/test_rdoc_generator_darkfish.rb +++ b/test/rdoc/test_rdoc_generator_darkfish.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocGeneratorDarkfish < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb index 52c35a564d..6cb5463d29 100644 --- a/test/rdoc/test_rdoc_generator_json_index.rb +++ b/test/rdoc/test_rdoc_generator_json_index.rb @@ -1,5 +1,5 @@ # coding: US-ASCII -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' @@ -199,7 +199,7 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase def test_generate_utf_8 text = "5\xB0" - text.force_encoding Encoding::ISO_8859_1 + text = RDoc::Encoding.change_encoding text, Encoding::ISO_8859_1 @klass.add_comment comment(text), @top_level @g.generate @@ -215,7 +215,7 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase klass_record = @klass.search_record[2..-1] klass_record[-1] = "<p>5\xc2\xb0\n" - klass_record.last.force_encoding Encoding::UTF_8 + klass_record[-1] = RDoc::Encoding.change_encoding klass_record[-1], Encoding::UTF_8 info = [ klass_record, diff --git a/test/rdoc/test_rdoc_generator_markup.rb b/test/rdoc/test_rdoc_generator_markup.rb index d546c2f87f..d13f5119be 100644 --- a/test/rdoc/test_rdoc_generator_markup.rb +++ b/test/rdoc/test_rdoc_generator_markup.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocGeneratorMarkup < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_generator_pot.rb b/test/rdoc/test_rdoc_generator_pot.rb index 3f1bee70c9..5675f96b75 100644 --- a/test/rdoc/test_rdoc_generator_pot.rb +++ b/test/rdoc/test_rdoc_generator_pot.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocGeneratorPOT < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_generator_pot_po.rb b/test/rdoc/test_rdoc_generator_pot_po.rb index ae60ff004e..8786f632c0 100644 --- a/test/rdoc/test_rdoc_generator_pot_po.rb +++ b/test/rdoc/test_rdoc_generator_pot_po.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocGeneratorPOTPO < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_generator_pot_po_entry.rb b/test/rdoc/test_rdoc_generator_pot_po_entry.rb index 36b85df864..5c24c2d70d 100644 --- a/test/rdoc/test_rdoc_generator_pot_po_entry.rb +++ b/test/rdoc/test_rdoc_generator_pot_po_entry.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocGeneratorPOTPOEntry < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_generator_ri.rb b/test/rdoc/test_rdoc_generator_ri.rb index d9f7b7ebc6..02bcee8904 100644 --- a/test/rdoc/test_rdoc_generator_ri.rb +++ b/test/rdoc/test_rdoc_generator_ri.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocGeneratorRI < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_i18n_locale.rb b/test/rdoc/test_rdoc_i18n_locale.rb index e9dce78472..ff9836f9a6 100644 --- a/test/rdoc/test_rdoc_i18n_locale.rb +++ b/test/rdoc/test_rdoc_i18n_locale.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocI18nLocale < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_i18n_text.rb b/test/rdoc/test_rdoc_i18n_text.rb index 4169b92079..be5ff581f5 100644 --- a/test/rdoc/test_rdoc_i18n_text.rb +++ b/test/rdoc/test_rdoc_i18n_text.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocI18nText < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_include.rb b/test/rdoc/test_rdoc_include.rb index 6a34f5d4b8..67d3dfd88e 100644 --- a/test/rdoc/test_rdoc_include.rb +++ b/test/rdoc/test_rdoc_include.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocInclude < XrefTestCase diff --git a/test/rdoc/test_rdoc_markdown.rb b/test/rdoc/test_rdoc_markdown.rb index 79b0175293..99f8abf5ab 100644 --- a/test/rdoc/test_rdoc_markdown.rb +++ b/test/rdoc/test_rdoc_markdown.rb @@ -1,5 +1,5 @@ # coding: UTF-8 -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' require 'rdoc/markup/block_quote' @@ -717,7 +717,7 @@ Some text. ^[With a footnote] def test_parse_note_no_notes @parser.notes = false - assert_raises RuntimeError do # TODO use a real error + assert_raises RDoc::Markdown::ParseError do parse "Some text.[^1]" end end @@ -930,6 +930,35 @@ and an extra note.[^2] assert_equal expected, doc end + def test_parse_strike_tilde + doc = parse "it ~~works~~\n" + + expected = @RM::Document.new( + @RM::Paragraph.new("it ~works~")) + + assert_equal expected, doc + end + + def test_parse_strike_words_tilde + doc = parse "it ~~works fine~~\n" + + expected = @RM::Document.new( + @RM::Paragraph.new("it <s>works fine</s>")) + + assert_equal expected, doc + end + + def test_parse_strike_tilde_no + @parser.strike = false + + doc = parse "it ~~works fine~~\n" + + expected = @RM::Document.new( + @RM::Paragraph.new("it ~~works fine~~")) + + assert_equal expected, doc + end + def test_parse_style @parser.css = true diff --git a/test/rdoc/test_rdoc_markdown_test.rb b/test/rdoc/test_rdoc_markdown_test.rb index e738832fed..8664ac45a0 100644 --- a/test/rdoc/test_rdoc_markdown_test.rb +++ b/test/rdoc/test_rdoc_markdown_test.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'minitest/autorun' require 'pp' diff --git a/test/rdoc/test_rdoc_markup.rb b/test/rdoc/test_rdoc_markup.rb index ad13211f7b..8e4e8b968e 100644 --- a/test/rdoc/test_rdoc_markup.rb +++ b/test/rdoc/test_rdoc_markup.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkup < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_attribute_manager.rb b/test/rdoc/test_rdoc_markup_attribute_manager.rb index c0f7666a01..a939623e01 100644 --- a/test/rdoc/test_rdoc_markup_attribute_manager.rb +++ b/test/rdoc/test_rdoc_markup_attribute_manager.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupAttributeManager < RDoc::TestCase @@ -171,21 +171,21 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase end def test_convert_attrs - str = '+foo+' + str = '+foo+'.dup attrs = RDoc::Markup::AttrSpan.new str.length @am.convert_attrs str, attrs assert_equal "\000foo\000", str - str = '+:foo:+' + str = '+:foo:+'.dup attrs = RDoc::Markup::AttrSpan.new str.length @am.convert_attrs str, attrs assert_equal "\000:foo:\000", str - str = '+x-y+' + str = '+x-y+'.dup attrs = RDoc::Markup::AttrSpan.new str.length @am.convert_attrs str, attrs @@ -299,17 +299,17 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase def @am.str() @str end def @am.str=(str) @str = str end - @am.str = '<code>foo</code>' + @am.str = '<code>foo</code>'.dup @am.mask_protected_sequences assert_equal "<code>foo</code>", @am.str - @am.str = '<code>foo\\</code>' + @am.str = '<code>foo\\</code>'.dup @am.mask_protected_sequences assert_equal "<code>foo<\x04/code>", @am.str, 'escaped close' - @am.str = '<code>foo\\\\</code>' + @am.str = '<code>foo\\\\</code>'.dup @am.mask_protected_sequences assert_equal "<code>foo\\</code>", @am.str, 'escaped backslash' @@ -332,6 +332,14 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase @am.flow("\\_cat_<i>dog</i>")) end + def test_lost_tag_for_the_second_time + str = "cat <tt>dog</tt>" + assert_equal(["cat ", @tt_on, "dog", @tt_off], + @am.flow(str)) + assert_equal(["cat ", @tt_on, "dog", @tt_off], + @am.flow(str)) + end + def test_special @am.add_special(RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF) diff --git a/test/rdoc/test_rdoc_markup_attributes.rb b/test/rdoc/test_rdoc_markup_attributes.rb index 077b6a5474..1fad62208c 100644 --- a/test/rdoc/test_rdoc_markup_attributes.rb +++ b/test/rdoc/test_rdoc_markup_attributes.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupAttributes < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_document.rb b/test/rdoc/test_rdoc_markup_document.rb index e5a61daea5..d817f1b9aa 100644 --- a/test/rdoc/test_rdoc_markup_document.rb +++ b/test/rdoc/test_rdoc_markup_document.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupDocument < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_formatter.rb b/test/rdoc/test_rdoc_markup_formatter.rb index 02a6844a3a..0e7f72fb16 100644 --- a/test/rdoc/test_rdoc_markup_formatter.rb +++ b/test/rdoc/test_rdoc_markup_formatter.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupFormatter < RDoc::TestCase @@ -12,7 +12,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase end def accept_paragraph paragraph - @res << attributes(paragraph.text) + @res += attributes(paragraph.text) end def attributes text diff --git a/test/rdoc/test_rdoc_markup_hard_break.rb b/test/rdoc/test_rdoc_markup_hard_break.rb index 5d2d359646..d93d52eeda 100644 --- a/test/rdoc/test_rdoc_markup_hard_break.rb +++ b/test/rdoc/test_rdoc_markup_hard_break.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupHardBreak < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_heading.rb b/test/rdoc/test_rdoc_markup_heading.rb index 463df7ef43..33e29e90e6 100644 --- a/test/rdoc/test_rdoc_markup_heading.rb +++ b/test/rdoc/test_rdoc_markup_heading.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupHeading < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_include.rb b/test/rdoc/test_rdoc_markup_include.rb index e72a0ac1bb..28712fa7ed 100644 --- a/test/rdoc/test_rdoc_markup_include.rb +++ b/test/rdoc/test_rdoc_markup_include.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupInclude < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_indented_paragraph.rb b/test/rdoc/test_rdoc_markup_indented_paragraph.rb index efcd840453..53d44dcec2 100644 --- a/test/rdoc/test_rdoc_markup_indented_paragraph.rb +++ b/test/rdoc/test_rdoc_markup_indented_paragraph.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupIndentedParagraph < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_paragraph.rb b/test/rdoc/test_rdoc_markup_paragraph.rb index 6da6658c6f..dce3ed8efd 100644 --- a/test/rdoc/test_rdoc_markup_paragraph.rb +++ b/test/rdoc/test_rdoc_markup_paragraph.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupParagraph < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_parser.rb b/test/rdoc/test_rdoc_markup_parser.rb index 849d19f8c7..fa4730a06f 100644 --- a/test/rdoc/test_rdoc_markup_parser.rb +++ b/test/rdoc/test_rdoc_markup_parser.rb @@ -1,5 +1,5 @@ # coding: utf-8 -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' diff --git a/test/rdoc/test_rdoc_markup_pre_process.rb b/test/rdoc/test_rdoc_markup_pre_process.rb index be3fdcbef3..3e0e505b0b 100644 --- a/test/rdoc/test_rdoc_markup_pre_process.rb +++ b/test/rdoc/test_rdoc_markup_pre_process.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' @@ -86,8 +86,7 @@ contents of a string. text = "# :main: M\n" out = @pp.handle text - assert_same out, text - assert_equal "#\n", text + assert_equal "#\n", out end def test_handle_comment @@ -96,8 +95,7 @@ contents of a string. out = @pp.handle c - assert_same out, text - assert_equal "#\n", text + assert_equal "#\n", out end def test_handle_markup @@ -129,8 +127,7 @@ contents of a string. out = @pp.handle text, cd - assert_same out, text - assert_equal "# a b c\n", text + assert_equal "# a b c\n", out assert_equal "# a b c\n", cd.metadata[:stuff] end @@ -138,8 +135,7 @@ contents of a string. text = "# :x: y\n" out = @pp.handle text - assert_same out, text - assert_equal "# :x: y\n", text + assert_equal text, out end def test_handle_directive_blankline diff --git a/test/rdoc/test_rdoc_markup_raw.rb b/test/rdoc/test_rdoc_markup_raw.rb index 1453333b9e..aaf4e48439 100644 --- a/test/rdoc/test_rdoc_markup_raw.rb +++ b/test/rdoc/test_rdoc_markup_raw.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupRaw < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_to_ansi.rb b/test/rdoc/test_rdoc_markup_to_ansi.rb index 8bd49271c1..d06ad98fa3 100644 --- a/test/rdoc/test_rdoc_markup_to_ansi.rb +++ b/test/rdoc/test_rdoc_markup_to_ansi.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToAnsi < RDoc::Markup::TextFormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_bs.rb b/test/rdoc/test_rdoc_markup_to_bs.rb index 153a121d78..9b798c92b3 100644 --- a/test/rdoc/test_rdoc_markup_to_bs.rb +++ b/test/rdoc/test_rdoc_markup_to_bs.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToBs < RDoc::Markup::TextFormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb index b5edeb04d2..fa5828a007 100644 --- a/test/rdoc/test_rdoc_markup_to_html.rb +++ b/test/rdoc/test_rdoc_markup_to_html.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @@ -452,9 +452,6 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase end def test_accept_verbatim_nl_after_backslash - # TODO: Remove "skip" after the issue is resolved: https://github.com/jruby/jruby/issues/4787 - # This "skip" is for strange behavior around escaped newline on JRuby - skip if defined? JRUBY_VERSION verb = @RM::Verbatim.new("a = 1 if first_flag_var and \\\n", " this_is_flag_var\n") @to.start_accepting @@ -520,7 +517,7 @@ end expected = <<-'EXPECTED' -<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier">foo</span> +<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">foo</span> [ <span class="ruby-string">'\\'</span>, <span class="ruby-string">'\''</span>, @@ -540,7 +537,7 @@ end <span class="ruby-regexp">/#{}/</span> ] <span class="ruby-keyword">end</span> -<span class="ruby-keyword">def</span> <span class="ruby-identifier">bar</span> +<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bar</span> <span class="ruby-keyword">end</span> </pre> EXPECTED @@ -570,7 +567,7 @@ end expected = <<-'EXPECTED' -<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier">foo</span> +<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">foo</span> [ <span class="ruby-string">`\\`</span>, <span class="ruby-string">`\'\"\``</span>, @@ -580,7 +577,7 @@ end <span class="ruby-node">`#{}`</span> ] <span class="ruby-keyword">end</span> -<span class="ruby-keyword">def</span> <span class="ruby-identifier">bar</span> +<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bar</span> <span class="ruby-keyword">end</span> </pre> EXPECTED @@ -622,7 +619,7 @@ end %w[| ^ & <=> == === =~ > >= < <= << >> + - * / % ** ~ +@ -@ [] []= ` ! != !~].each do |html_escaped_op| expected += <<-EXPECTED -<span class="ruby-keyword">def</span> <span class="ruby-identifier">#{html_escaped_op}</span> +<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">#{html_escaped_op}</span> <span class="ruby-keyword">end</span> EXPECTED end diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb index b9b5629554..73b76de4d9 100644 --- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb +++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocMarkupToHtmlCrossref < XrefTestCase diff --git a/test/rdoc/test_rdoc_markup_to_html_snippet.rb b/test/rdoc/test_rdoc_markup_to_html_snippet.rb index 19c534863e..d7ce211999 100644 --- a/test/rdoc/test_rdoc_markup_to_html_snippet.rb +++ b/test/rdoc/test_rdoc_markup_to_html_snippet.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase @@ -604,7 +604,7 @@ This routine modifies its +comment+ parameter. rdoc = "* text\n" * 2 expected = "<p>text\n" - expected.chomp! + expected = expected.chomp expected << " #{@ellipsis}\n" actual = @to.convert rdoc diff --git a/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb b/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb index 414b7d3732..0a6a864bfa 100644 --- a/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb +++ b/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToJoinedParagraph < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_to_label.rb b/test/rdoc/test_rdoc_markup_to_label.rb index 35df69c2ac..23ab8cbfab 100644 --- a/test/rdoc/test_rdoc_markup_to_label.rb +++ b/test/rdoc/test_rdoc_markup_to_label.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_markdown.rb b/test/rdoc/test_rdoc_markup_to_markdown.rb index a72f30ee01..f5ea8d05da 100644 --- a/test/rdoc/test_rdoc_markup_to_markdown.rb +++ b/test/rdoc/test_rdoc_markup_to_markdown.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToMarkdown < RDoc::Markup::TextFormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_rdoc.rb b/test/rdoc/test_rdoc_markup_to_rdoc.rb index 0dce0a0d5a..31761eb44d 100644 --- a/test/rdoc/test_rdoc_markup_to_rdoc.rb +++ b/test/rdoc/test_rdoc_markup_to_rdoc.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_table_of_contents.rb b/test/rdoc/test_rdoc_markup_to_table_of_contents.rb index acfa807948..f21dbfe748 100644 --- a/test/rdoc/test_rdoc_markup_to_table_of_contents.rb +++ b/test/rdoc/test_rdoc_markup_to_table_of_contents.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToTableOfContents < RDoc::Markup::FormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_tt_only.rb b/test/rdoc/test_rdoc_markup_to_tt_only.rb index a7918c90ab..b08362cd0b 100644 --- a/test/rdoc/test_rdoc_markup_to_tt_only.rb +++ b/test/rdoc/test_rdoc_markup_to_tt_only.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_verbatim.rb b/test/rdoc/test_rdoc_markup_verbatim.rb index 6fdf8fde28..3b05100a33 100644 --- a/test/rdoc/test_rdoc_markup_verbatim.rb +++ b/test/rdoc/test_rdoc_markup_verbatim.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocMarkupVerbatim < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_method_attr.rb b/test/rdoc/test_rdoc_method_attr.rb index 70f129ef32..68a9d6cc21 100644 --- a/test/rdoc/test_rdoc_method_attr.rb +++ b/test/rdoc/test_rdoc_method_attr.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocMethodAttr < XrefTestCase diff --git a/test/rdoc/test_rdoc_normal_class.rb b/test/rdoc/test_rdoc_normal_class.rb index 9153bdc839..874eaaa88c 100644 --- a/test/rdoc/test_rdoc_normal_class.rb +++ b/test/rdoc/test_rdoc_normal_class.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocNormalClass < XrefTestCase diff --git a/test/rdoc/test_rdoc_normal_module.rb b/test/rdoc/test_rdoc_normal_module.rb index d92a72e7bf..68e776c41f 100644 --- a/test/rdoc/test_rdoc_normal_module.rb +++ b/test/rdoc/test_rdoc_normal_module.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocNormalModule < XrefTestCase diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb index eef37b44b4..760cf9db55 100644 --- a/test/rdoc/test_rdoc_options.rb +++ b/test/rdoc/test_rdoc_options.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocOptions < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb index b71d89b064..5d4da7e425 100644 --- a/test/rdoc/test_rdoc_parser.rb +++ b/test/rdoc/test_rdoc_parser.rb @@ -1,5 +1,5 @@ # -*- coding: us-ascii -*- -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb index 5341da16e2..2cc8ddf79a 100644 --- a/test/rdoc/test_rdoc_parser_c.rb +++ b/test/rdoc/test_rdoc_parser_c.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' =begin @@ -357,6 +357,25 @@ VALUE cFoo = rb_define_class("Foo", rb_cObject); assert_equal "this is the Foo class", klass.comment.text end + def test_do_classes_duplicate_class + content = <<-EOF +/* Document-class: Foo + * first + */ +VALUE cFoo = rb_define_class("Foo", rb_cObject); +/* Document-class: Foo + * second + */ +VALUE cFoo = rb_define_class("Foo", rb_cObject); + EOF + + klass = util_get_class content, 'cFoo' + assert_equal 1, klass.comment_location.size + first = klass.comment_location.first + first_comment = first[0] + assert_equal 'first', first_comment.text + end + def test_do_classes_struct content = <<-EOF /* Document-class: Foo @@ -642,6 +661,7 @@ void Init_Blah(void) { klass = util_get_class content, 'cDate' end + assert_equal 'Date', klass.full_name assert_match ' blah.c ', err end @@ -664,6 +684,7 @@ void Init_Blah(void) { klass = util_get_class content, 'cDate' end + assert_equal 'Date', klass.full_name assert_match ' blah.cpp ', err end @@ -686,6 +707,7 @@ void Init_Blah(void) { klass = util_get_class content, 'cDate' end + assert_equal 'Date', klass.full_name assert_match ' blah.y ', err end diff --git a/test/rdoc/test_rdoc_parser_changelog.rb b/test/rdoc/test_rdoc_parser_changelog.rb index 0135d26d87..06c3ff206e 100644 --- a/test/rdoc/test_rdoc_parser_changelog.rb +++ b/test/rdoc/test_rdoc_parser_changelog.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocParserChangeLog < RDoc::TestCase @@ -33,7 +33,7 @@ class TestRDocParserChangeLog < RDoc::TestCase def test_continue_entry_body parser = util_parser - entry_body = ['a'] + entry_body = ['a'.dup] parser.continue_entry_body entry_body, 'b' @@ -53,7 +53,7 @@ class TestRDocParserChangeLog < RDoc::TestCase def test_continue_entry_body_function parser = util_parser - entry_body = ['file: (func1)'] + entry_body = ['file: (func1)'.dup] parser.continue_entry_body entry_body, '(func2): blah' diff --git a/test/rdoc/test_rdoc_parser_markdown.rb b/test/rdoc/test_rdoc_parser_markdown.rb index a8a8402946..50893ecf99 100644 --- a/test/rdoc/test_rdoc_parser_markdown.rb +++ b/test/rdoc/test_rdoc_parser_markdown.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocParserMarkdown < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_parser_rd.rb b/test/rdoc/test_rdoc_parser_rd.rb index 481d190ffe..e8f4250284 100644 --- a/test/rdoc/test_rdoc_parser_rd.rb +++ b/test/rdoc/test_rdoc_parser_rd.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocParserRd < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index e9e3fcf246..e28112fbee 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' @@ -681,6 +681,32 @@ end assert_equal @top_level, blah.file end + def test_parse_class_in_a_file_repeatedly + @filename = 'a.rb' + comment_a = RDoc::Comment.new "# aaa\n", @top_level + util_parser "class Foo\nend" + tk = @parser.get_tk + @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment_a + comment_b = RDoc::Comment.new "# bbb\n", @top_level + util_parser "class Foo\nend" + tk = @parser.get_tk + @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment_b + + @filename = 'b.rb' + comment_c = RDoc::Comment.new "# ccc\n", @top_level + util_parser "class Foo\nend" + tk = @parser.get_tk + @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment_c + + foo = @top_level.classes.first + assert_equal 'Foo', foo.full_name + assert_equal [[comment_a, @top_level], + [comment_b, @top_level], + [comment_c, @top_level]], foo.comment_location + assert_equal [@top_level], foo.in_files + assert_equal 1, foo.line + end + def test_parse_class_ghost_method_yields util_parser <<-CLASS class Foo @@ -1392,7 +1418,7 @@ end RUBY expected = <<EXPECTED -<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">foo</span> +<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">foo</span> <span class="ruby-constant">A</span><span class="ruby-operator">::</span><span class="ruby-constant">B</span><span class="ruby-operator">::</span><span class="ruby-constant">C</span> <span class="ruby-keyword">end</span> EXPECTED @@ -1762,6 +1788,28 @@ end end end + def test_parse_method_with_args_directive + util_parser <<-RUBY +class C + def meth_with_args_after # :args: a, b, c + end + + ## + # :args: d, e, f + def meth_with_args_before +end + RUBY + + @parser.scan + + c = @store.find_class_named 'C' + + assert_equal 'C#meth_with_args_after', c.method_list[0].full_name + assert_equal 'a, b, c', c.method_list[0].params + assert_equal 'C#meth_with_args_before', c.method_list[1].full_name + assert_equal 'd, e, f', c.method_list[1].params + end + def test_parse_method_bracket util_parser <<-RUBY class C @@ -2607,7 +2655,7 @@ end RUBY expected = <<EXPECTED -<span class="ruby-keyword">def</span> <span class="ruby-identifier">blah</span>() +<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">blah</span>() <span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> (<span class="ruby-identifier">k</span>)<span class="ruby-operator">...</span><span class="ruby-identifier">n</span> <span class="ruby-keyword">do</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> (<span class="ruby-identifier">k</span>)<span class="ruby-operator">...</span><span class="ruby-identifier">n</span> @@ -2626,6 +2674,29 @@ EXPECTED assert_equal expected, markup_code end + def test_parse_instance_operation_method + util_parser <<-RUBY +class Foo + def self.& end +end + RUBY + + expected = <<EXPECTED + <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">&</span> <span class="ruby-keyword">end</span> +<span class="ruby-keyword">end</span> +EXPECTED + expected = expected.rstrip + + @parser.scan + + foo = @top_level.classes.first + assert_equal 'Foo', foo.full_name + + blah = foo.method_list.first + markup_code = blah.markup_code.sub(/^.*\n/, '') + assert_equal expected, markup_code + end + def test_parse_statements_postfix_if_after_heredocbeg @filename = 'file.rb' util_parser <<RUBY @@ -2638,7 +2709,7 @@ end RUBY expected = <<EXPECTED - <span class="ruby-keyword">def</span> <span class="ruby-identifier">blah</span>() + <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">blah</span>() <span class="ruby-identifier"><<-EOM</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">true</span> <span class="ruby-value"></span><span class="ruby-identifier"> EOM</span> <span class="ruby-keyword">end</span> @@ -2663,7 +2734,7 @@ end RUBY expected = <<EXPECTED -<span class="ruby-keyword">def</span> <span class="ruby-identifier">blah</span>() <span class="ruby-regexp">/bar/</span> <span class="ruby-keyword">end</span> +<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">blah</span>() <span class="ruby-regexp">/bar/</span> <span class="ruby-keyword">end</span> EXPECTED expected = expected.rstrip @@ -2778,7 +2849,7 @@ RUBY assert_nil m.params, 'Module parameter not removed' end - def test_parse_statements_stopdoc_TkALIAS + def test_parse_statements_stopdoc_alias klass = @top_level.add_class RDoc::NormalClass, 'Foo' util_parser "\n# :stopdoc:\nalias old new" @@ -2789,7 +2860,7 @@ RUBY assert_empty klass.unmatched_alias_lists end - def test_parse_statements_stopdoc_TkIDENTIFIER_alias_method + def test_parse_statements_stopdoc_identifier_alias_method klass = @top_level.add_class RDoc::NormalClass, 'Foo' util_parser "\n# :stopdoc:\nalias_method :old :new" @@ -2800,7 +2871,7 @@ RUBY assert_empty klass.unmatched_alias_lists end - def test_parse_statements_stopdoc_TkIDENTIFIER_metaprogrammed + def test_parse_statements_stopdoc_identifier_metaprogrammed klass = @top_level.add_class RDoc::NormalClass, 'Foo' util_parser "\n# :stopdoc:\n# attr :meta" @@ -2811,7 +2882,7 @@ RUBY assert_empty klass.attributes end - def test_parse_statements_stopdoc_TkCONSTANT + def test_parse_statements_stopdoc_constant klass = @top_level.add_class RDoc::NormalClass, 'Foo' util_parser "\n# :stopdoc:\nA = v" @@ -2821,7 +2892,7 @@ RUBY assert_empty klass.constants end - def test_parse_statements_stopdoc_TkDEF + def test_parse_statements_stopdoc_def klass = @top_level.add_class RDoc::NormalClass, 'Foo' util_parser "\n# :stopdoc:\ndef m\n end" @@ -3393,6 +3464,7 @@ end foo = @top_level.modules.first expected = [ + RDoc::Comment.new('comment a', @top_level), RDoc::Comment.new('comment b', @top_level) ] @@ -3758,21 +3830,6 @@ end assert_equal 'there', baz.comment.text end - def tk klass, scan, line, char, name, text - klass = RDoc::RubyToken.const_get "Tk#{klass.to_s.upcase}" - - token = if klass.instance_method(:initialize).arity == 3 then - raise ArgumentError, "name not used for #{klass}" if name - klass.new scan, line, char - else - klass.new scan, line, char, name - end - - token.set_text text - - token - end - def util_parser(content) @parser = RDoc::Parser::Ruby.new @top_level, @filename, content, @options, @stats diff --git a/test/rdoc/test_rdoc_parser_simple.rb b/test/rdoc/test_rdoc_parser_simple.rb index 0e2cf0d9a9..cdbcd7929d 100644 --- a/test/rdoc/test_rdoc_parser_simple.rb +++ b/test/rdoc/test_rdoc_parser_simple.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocParserSimple < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_rd.rb b/test/rdoc/test_rdoc_rd.rb index 938c5569f9..ed67ae2caa 100644 --- a/test/rdoc/test_rdoc_rd.rb +++ b/test/rdoc/test_rdoc_rd.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocRd < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_rd_block_parser.rb b/test/rdoc/test_rdoc_rd_block_parser.rb index 18ec30db0f..a73c206508 100644 --- a/test/rdoc/test_rdoc_rd_block_parser.rb +++ b/test/rdoc/test_rdoc_rd_block_parser.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocRdBlockParser < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_rd_inline.rb b/test/rdoc/test_rdoc_rd_inline.rb index d4448e4397..2869681c6e 100644 --- a/test/rdoc/test_rdoc_rd_inline.rb +++ b/test/rdoc/test_rdoc_rd_inline.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocRdInline < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_rd_inline_parser.rb b/test/rdoc/test_rdoc_rd_inline_parser.rb index eb022b240f..b4394019b3 100644 --- a/test/rdoc/test_rdoc_rd_inline_parser.rb +++ b/test/rdoc/test_rdoc_rd_inline_parser.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocRdInlineParser < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 39f54555b5..3244238e3c 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocRDoc < RDoc::TestCase @@ -40,6 +40,34 @@ class TestRDocRDoc < RDoc::TestCase assert_equal 'title', store.title end + def test_document_with_dry_run # functional test + options = RDoc::Options.new + options.files = [File.expand_path('../xref_data.rb', __FILE__)] + options.setup_generator 'darkfish' + options.main_page = 'MAIN_PAGE.rdoc' + options.root = Pathname File.expand_path('..', __FILE__) + options.title = 'title' + options.dry_run = true + + rdoc = RDoc::RDoc.new + + out = nil + temp_dir do + out, = capture_io do + rdoc.document options + end + + refute File.directory? 'doc' + assert_equal rdoc, rdoc.store.rdoc + end + assert_includes out, '100%' + + store = rdoc.store + + assert_equal 'MAIN_PAGE.rdoc', store.main + assert_equal 'title', store.title + end + def test_gather_files a = File.expand_path __FILE__ b = File.expand_path '../test_rdoc_text.rb', __FILE__ @@ -109,17 +137,18 @@ class TestRDocRDoc < RDoc::TestCase end def test_normalized_file_list + test_path = File.expand_path(__FILE__) files = temp_dir do |dir| flag_file = @rdoc.output_flag_file dir FileUtils.touch flag_file - @rdoc.normalized_file_list [__FILE__, flag_file] + @rdoc.normalized_file_list [test_path, flag_file] end files = files.map { |file| File.expand_path file } - assert_equal [File.expand_path(__FILE__)], files + assert_equal [test_path], files end def test_normalized_file_list_not_modified @@ -189,9 +218,10 @@ class TestRDocRDoc < RDoc::TestCase def test_parse_file_include_root @rdoc.store = RDoc::Store.new + test_path = File.expand_path('..', __FILE__) top_level = nil temp_dir do |dir| - @rdoc.options.parse %W[--root #{File.dirname(__FILE__)}] + @rdoc.options.parse %W[--root #{test_path}] open 'include.txt', 'w' do |io| io.puts ':include: test.txt' diff --git a/test/rdoc/test_rdoc_require.rb b/test/rdoc/test_rdoc_require.rb index cbedf5c8a4..46c225299a 100644 --- a/test/rdoc/test_rdoc_require.rb +++ b/test/rdoc/test_rdoc_require.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocRequire < XrefTestCase @@ -12,13 +12,13 @@ class TestRDocRequire < XrefTestCase def test_initialize assert_equal 'foo', @req.name - req = RDoc::Require.new '"foo"', '' + RDoc::Require.new '"foo"', '' assert_equal 'foo', @req.name - req = RDoc::Require.new '\'foo\'', '' + RDoc::Require.new '\'foo\'', '' assert_equal 'foo', @req.name - req = RDoc::Require.new '|foo|', '' + RDoc::Require.new '|foo|', '' assert_equal 'foo', @req.name, 'for fortran?' end diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb index 81c8469e25..687d0968df 100644 --- a/test/rdoc/test_rdoc_ri_driver.rb +++ b/test/rdoc/test_rdoc_ri_driver.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocRIDriver < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_ri_paths.rb b/test/rdoc/test_rdoc_ri_paths.rb index 06968b5510..b0f368353a 100644 --- a/test/rdoc/test_rdoc_ri_paths.rb +++ b/test/rdoc/test_rdoc_ri_paths.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocRIPaths < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb index ee16f3d95c..2fb79ff577 100644 --- a/test/rdoc/test_rdoc_rubygems_hook.rb +++ b/test/rdoc/test_rdoc_rubygems_hook.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rubygems/test_case' require 'rdoc/rubygems_hook' diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb index 947d8c896c..4dd1f08ddd 100644 --- a/test/rdoc/test_rdoc_servlet.rb +++ b/test/rdoc/test_rdoc_servlet.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocServlet < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_single_class.rb b/test/rdoc/test_rdoc_single_class.rb index 85a99d2229..5761bfef4d 100644 --- a/test/rdoc/test_rdoc_single_class.rb +++ b/test/rdoc/test_rdoc_single_class.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocSingleClass < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_stats.rb b/test/rdoc/test_rdoc_stats.rb index 34e1417783..19fc2365b3 100644 --- a/test/rdoc/test_rdoc_stats.rb +++ b/test/rdoc/test_rdoc_stats.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocStats < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb index d32eab3ec1..4a4cf3ac0f 100644 --- a/test/rdoc/test_rdoc_store.rb +++ b/test/rdoc/test_rdoc_store.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocStore < XrefTestCase diff --git a/test/rdoc/test_rdoc_task.rb b/test/rdoc/test_rdoc_task.rb index bb5d2ae134..ac3512f42a 100644 --- a/test/rdoc/test_rdoc_task.rb +++ b/test/rdoc/test_rdoc_task.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' begin require 'rake' diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index 7a125854b5..9f0e9480d3 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' @@ -61,7 +61,7 @@ class TestRDocText < RDoc::TestCase def test_expand_tabs_encoding inn = "hello\ns\tdave" - inn.force_encoding Encoding::BINARY + inn = RDoc::Encoding.change_encoding inn, Encoding::BINARY out = expand_tabs inn @@ -95,7 +95,7 @@ The comments associated with The comments associated with TEXT - text.force_encoding Encoding::US_ASCII + text = RDoc::Encoding.change_encoding text, Encoding::US_ASCII expected = <<-EXPECTED @@ -303,7 +303,7 @@ paragraph will be cut off … # The comments associated with TEXT - text.force_encoding Encoding::CP852 + text = RDoc::Encoding.change_encoding text, Encoding::CP852 expected = <<-EXPECTED @@ -332,7 +332,7 @@ paragraph will be cut off … assert_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check' text = " \n" - text.force_encoding Encoding::US_ASCII + text = RDoc::Encoding.change_encoding text, Encoding::US_ASCII stripped = strip_newlines text @@ -386,7 +386,7 @@ paragraph will be cut off … */ TEXT - text.force_encoding Encoding::CP852 + text = RDoc::Encoding.change_encoding text, Encoding::CP852 expected = <<-EXPECTED @@ -410,7 +410,7 @@ paragraph will be cut off … */ TEXT - text.force_encoding Encoding::BINARY + text = RDoc::Encoding.change_encoding text, Encoding::BINARY expected = <<-EXPECTED diff --git a/test/rdoc/test_rdoc_token_stream.rb b/test/rdoc/test_rdoc_token_stream.rb index 95c3ffd13e..abf1469bbc 100644 --- a/test/rdoc/test_rdoc_token_stream.rb +++ b/test/rdoc/test_rdoc_token_stream.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocTokenStream < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_tom_doc.rb b/test/rdoc/test_rdoc_tom_doc.rb index 7076edfa72..15bbd9b32d 100644 --- a/test/rdoc/test_rdoc_tom_doc.rb +++ b/test/rdoc/test_rdoc_tom_doc.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/test_case' class TestRDocTomDoc < RDoc::TestCase @@ -131,7 +131,7 @@ here - something def test_parse_multiline_paragraph text = "Public: Do some stuff\n" - text << "On a new line\n" + text += "On a new line\n" expected = doc( @@ -353,7 +353,7 @@ Signature def test_tokenize_multiline_paragraph text = "Public: Do some stuff\n" - text << "On a new line\n" + text += "On a new line\n" @td.tokenize text diff --git a/test/rdoc/test_rdoc_top_level.rb b/test/rdoc/test_rdoc_top_level.rb index b8145e3f9d..00fc7a1bd5 100644 --- a/test/rdoc/test_rdoc_top_level.rb +++ b/test/rdoc/test_rdoc_top_level.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require File.expand_path '../xref_test_case', __FILE__ class TestRDocTopLevel < XrefTestCase diff --git a/test/rdoc/xref_data.rb b/test/rdoc/xref_data.rb index c712ab8891..bc20d8ed91 100644 --- a/test/rdoc/xref_data.rb +++ b/test/rdoc/xref_data.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true XREF_DATA = <<-XREF_DATA class C1 diff --git a/test/rdoc/xref_test_case.rb b/test/rdoc/xref_test_case.rb index 9b2f876e5a..9f709964c6 100644 --- a/test/rdoc/xref_test_case.rb +++ b/test/rdoc/xref_test_case.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ENV['RDOC_TEST'] = 'yes' require 'rdoc' |