2015-12-16 08:07:31 +03:00
|
|
|
# frozen_string_literal: false
|
2012-11-27 08:28:14 +04:00
|
|
|
require 'rdoc/test_case'
|
2010-12-29 01:08:56 +03:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
class TestRDocStats < RDoc::TestCase
|
2010-12-29 01:08:56 +03:00
|
|
|
|
|
|
|
def setup
|
2012-11-27 08:28:14 +04:00
|
|
|
super
|
2010-12-29 01:08:56 +03:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@s = RDoc::Stats.new @store, 0
|
|
|
|
|
|
|
|
@tl = @store.add_file 'file.rb'
|
|
|
|
@tl.parser = RDoc::Parser::Ruby
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_doc_stats
|
|
|
|
c = RDoc::CodeObject.new
|
|
|
|
|
|
|
|
assert_equal [1, 1], @s.doc_stats([c])
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_doc_stats_documented
|
|
|
|
c = RDoc::CodeObject.new
|
|
|
|
c.comment = comment 'x'
|
|
|
|
|
|
|
|
assert_equal [1, 0], @s.doc_stats([c])
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_doc_stats_display_eh
|
|
|
|
c = RDoc::CodeObject.new
|
|
|
|
c.ignore
|
|
|
|
|
|
|
|
assert_equal [0, 0], @s.doc_stats([c])
|
2010-12-29 01:08:56 +03:00
|
|
|
end
|
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
def test_report_attr
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
a = RDoc::Attr.new nil, 'a', 'RW', nil
|
2012-11-27 08:28:14 +04:00
|
|
|
a.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_attribute a
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
verb(
|
|
|
|
"class C # is documented\n",
|
|
|
|
"\n",
|
|
|
|
" attr_accessor :a # in file file.rb\n",
|
|
|
|
"\n",
|
|
|
|
"end\n"),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_attr_documented
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
a = RDoc::Attr.new nil, 'a', 'RW', 'a'
|
2012-11-27 08:28:14 +04:00
|
|
|
a.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_attribute a
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
|
|
|
assert_equal @s.great_job, report
|
|
|
|
end
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
def test_report_attr_line
|
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
|
|
|
|
|
|
|
a = RDoc::Attr.new nil, 'a', 'RW', nil
|
|
|
|
a.record_location @tl
|
|
|
|
a.line = 3
|
|
|
|
c.add_attribute a
|
|
|
|
|
|
|
|
@store.complete :public
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
assert_match '# in file file.rb:3', @s.report.accept(to_rdoc)
|
2012-11-27 08:28:14 +04:00
|
|
|
end
|
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
def test_report_constant
|
2012-11-27 08:28:14 +04:00
|
|
|
m = @tl.add_module RDoc::NormalModule, 'M'
|
|
|
|
m.record_location @tl
|
|
|
|
m.add_comment 'M', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
c = RDoc::Constant.new 'C', nil, nil
|
2012-11-27 08:28:14 +04:00
|
|
|
c.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
m.add_constant c
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
verb(
|
|
|
|
"module M # is documented\n",
|
|
|
|
"\n",
|
|
|
|
" # in file file.rb\n",
|
|
|
|
" C = nil\n",
|
|
|
|
"\n",
|
|
|
|
"end\n"),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
2010-12-29 01:08:56 +03:00
|
|
|
def test_report_constant_alias
|
2012-11-27 08:28:14 +04:00
|
|
|
mod = @tl.add_module RDoc::NormalModule, 'M'
|
2010-12-29 01:08:56 +03:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
2010-12-29 01:08:56 +03:00
|
|
|
mod.add_constant c
|
|
|
|
|
|
|
|
ca = RDoc::Constant.new 'CA', nil, nil
|
|
|
|
ca.is_alias_for = c
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@tl.add_constant ca
|
2010-12-29 01:08:56 +03:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2010-12-29 01:08:56 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
|
|
|
# TODO change this to refute match, aliases should be ignored as they are
|
|
|
|
# programmer convenience constructs
|
2013-09-19 03:33:36 +04:00
|
|
|
assert_match 'class Object', report.accept(to_rdoc)
|
2010-12-29 01:08:56 +03:00
|
|
|
end
|
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
def test_report_constant_documented
|
2012-11-27 08:28:14 +04:00
|
|
|
m = @tl.add_module RDoc::NormalModule, 'M'
|
|
|
|
m.record_location @tl
|
2013-09-19 03:33:36 +04:00
|
|
|
m.add_comment 'M', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
c = RDoc::Constant.new 'C', nil, 'C'
|
2012-11-27 08:28:14 +04:00
|
|
|
c.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
m.add_constant c
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
|
|
|
assert_equal @s.great_job, report
|
|
|
|
end
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
def test_report_constant_line
|
|
|
|
m = @tl.add_module RDoc::NormalModule, 'M'
|
|
|
|
m.record_location @tl
|
|
|
|
m.add_comment 'M', @tl
|
|
|
|
|
|
|
|
c = RDoc::Constant.new 'C', nil, nil
|
|
|
|
c.record_location @tl
|
|
|
|
c.line = 5
|
|
|
|
m.add_constant c
|
|
|
|
|
|
|
|
@store.complete :public
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
assert_match '# in file file.rb:5', @s.report.accept(to_rdoc)
|
2012-11-27 08:28:14 +04:00
|
|
|
end
|
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
def test_report_class
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m = RDoc::AnyMethod.new nil, 'm'
|
2012-11-27 08:28:14 +04:00
|
|
|
m.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_method m
|
|
|
|
m.comment = 'm'
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
para('In files:'),
|
|
|
|
list(:BULLET, *[
|
|
|
|
item(nil, para('file.rb'))]),
|
|
|
|
blank_line,
|
|
|
|
verb("class C\n", "end\n"),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
def test_report_skip_object
|
|
|
|
c = @tl.add_class RDoc::NormalClass, 'Object'
|
|
|
|
c.record_location @tl
|
|
|
|
|
|
|
|
m = RDoc::AnyMethod.new nil, 'm'
|
|
|
|
m.record_location @tl
|
|
|
|
c.add_method m
|
|
|
|
m.comment = 'm'
|
|
|
|
|
|
|
|
@store.complete :public
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
refute_match %r%^class Object$%, @s.report.accept(to_rdoc)
|
2012-11-27 08:28:14 +04:00
|
|
|
end
|
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
def test_report_class_documented
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m = RDoc::AnyMethod.new nil, 'm'
|
2012-11-27 08:28:14 +04:00
|
|
|
m.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_method m
|
|
|
|
m.comment = 'm'
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
|
|
|
assert_equal @s.great_job, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_class_documented_level_1
|
2012-11-27 08:28:14 +04:00
|
|
|
c1 = @tl.add_class RDoc::NormalClass, 'C1'
|
|
|
|
c1.record_location @tl
|
|
|
|
c1.add_comment 'C1', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m1 = RDoc::AnyMethod.new nil, 'm1'
|
2012-11-27 08:28:14 +04:00
|
|
|
m1.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c1.add_method m1
|
|
|
|
m1.comment = 'm1'
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
c2 = @tl.add_class RDoc::NormalClass, 'C2'
|
|
|
|
c2.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m2 = RDoc::AnyMethod.new nil, 'm2'
|
2012-11-27 08:28:14 +04:00
|
|
|
m2.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c2.add_method m2
|
|
|
|
m2.comment = 'm2'
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
@s.coverage_level = 1
|
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
para('In files:'),
|
|
|
|
list(:BULLET, *[
|
|
|
|
item(nil, para('file.rb'))]),
|
|
|
|
blank_line,
|
|
|
|
verb("class C2\n", "end\n"),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_class_empty
|
2012-11-27 08:28:14 +04:00
|
|
|
@tl.add_class RDoc::NormalClass, 'C'
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
para('class C is referenced but empty.'),
|
|
|
|
para("It probably came from another project. I'm sorry I'm holding it against you."),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_class_empty_2
|
2012-11-27 08:28:14 +04:00
|
|
|
c1 = @tl.add_class RDoc::NormalClass, 'C1'
|
|
|
|
c1.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
c2 = @tl.add_class RDoc::NormalClass, 'C2'
|
|
|
|
c2.record_location @tl
|
|
|
|
c2.add_comment 'C2', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
@s.coverage_level = 1
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
para('In files:'),
|
|
|
|
list(:BULLET, *[
|
|
|
|
item(nil, para('file.rb'))]),
|
|
|
|
blank_line,
|
|
|
|
verb("class C1\n", "end\n"),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_class_method_documented
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m = RDoc::AnyMethod.new nil, 'm'
|
2012-11-27 08:28:14 +04:00
|
|
|
m.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_method m
|
|
|
|
m.comment = 'm'
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
para('In files:'),
|
|
|
|
list(:BULLET, *[
|
|
|
|
item(nil, para('file.rb'))]),
|
|
|
|
blank_line,
|
|
|
|
verb("class C\n", "end\n"),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
def test_report_class_module_ignore
|
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.ignore
|
|
|
|
|
|
|
|
@store.complete :public
|
|
|
|
|
|
|
|
report = @s.report_class_module c
|
|
|
|
|
|
|
|
assert_nil report
|
|
|
|
end
|
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
def test_report_empty
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
|
|
|
assert_equal @s.great_job, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_method
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m1 = RDoc::AnyMethod.new nil, 'm1'
|
2012-11-27 08:28:14 +04:00
|
|
|
m1.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_method m1
|
|
|
|
|
|
|
|
m2 = RDoc::AnyMethod.new nil, 'm2'
|
2012-11-27 08:28:14 +04:00
|
|
|
m2.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_method m2
|
|
|
|
m2.comment = 'm2'
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
verb(*[
|
|
|
|
"class C # is documented\n",
|
|
|
|
"\n",
|
|
|
|
" # in file file.rb\n",
|
|
|
|
" def m1; end\n",
|
|
|
|
"\n",
|
|
|
|
"end\n"]),
|
|
|
|
blank_line)
|
2012-11-27 08:28:14 +04:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_method_class
|
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
|
|
|
|
|
|
|
m1 = RDoc::AnyMethod.new nil, 'm1'
|
|
|
|
m1.record_location @tl
|
|
|
|
m1.singleton = true
|
|
|
|
c.add_method m1
|
|
|
|
|
|
|
|
m2 = RDoc::AnyMethod.new nil, 'm2'
|
|
|
|
m2.record_location @tl
|
|
|
|
m2.singleton = true
|
|
|
|
c.add_method m2
|
|
|
|
m2.comment = 'm2'
|
|
|
|
|
|
|
|
@store.complete :public
|
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
verb(*[
|
|
|
|
"class C # is documented\n",
|
|
|
|
"\n",
|
|
|
|
" # in file file.rb\n",
|
|
|
|
" def self.m1; end\n",
|
|
|
|
"\n",
|
|
|
|
"end\n"]),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_method_documented
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m = RDoc::AnyMethod.new nil, 'm'
|
2012-11-27 08:28:14 +04:00
|
|
|
m.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_method m
|
|
|
|
m.comment = 'm'
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
report = @s.report
|
|
|
|
|
|
|
|
assert_equal @s.great_job, report
|
|
|
|
end
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
def test_report_method_line
|
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
|
|
|
|
|
|
|
m1 = RDoc::AnyMethod.new nil, 'm1'
|
|
|
|
m1.record_location @tl
|
|
|
|
m1.line = 4
|
|
|
|
c.add_method m1
|
|
|
|
|
|
|
|
@store.complete :public
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
assert_match '# in file file.rb:4', @s.report.accept(to_rdoc)
|
2012-11-27 08:28:14 +04:00
|
|
|
end
|
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
def test_report_method_parameters
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m1 = RDoc::AnyMethod.new nil, 'm1'
|
2012-11-27 08:28:14 +04:00
|
|
|
m1.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
m1.params = '(p1, p2)'
|
|
|
|
m1.comment = 'Stuff with +p1+'
|
|
|
|
c.add_method m1
|
|
|
|
|
|
|
|
m2 = RDoc::AnyMethod.new nil, 'm2'
|
2012-11-27 08:28:14 +04:00
|
|
|
m2.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_method m2
|
|
|
|
m2.comment = 'm2'
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
@s.coverage_level = 1
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
verb(*[
|
|
|
|
"class C # is documented\n",
|
|
|
|
"\n",
|
|
|
|
" # in file file.rb\n",
|
|
|
|
" # +p2+ is not documented\n",
|
|
|
|
" def m1(p1, p2); end\n",
|
|
|
|
"\n",
|
|
|
|
"end\n"]),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_method_parameters_documented
|
2012-11-27 08:28:14 +04:00
|
|
|
@tl.parser = RDoc::Parser::Ruby
|
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m = RDoc::AnyMethod.new nil, 'm'
|
2012-11-27 08:28:14 +04:00
|
|
|
m.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
m.params = '(p1)'
|
|
|
|
m.comment = 'Stuff with +p1+'
|
|
|
|
c.add_method m
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
@s.coverage_level = 1
|
|
|
|
report = @s.report
|
|
|
|
|
|
|
|
assert_equal @s.great_job, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_report_method_parameters_yield
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m = RDoc::AnyMethod.new nil, 'm'
|
2012-11-27 08:28:14 +04:00
|
|
|
m.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
m.call_seq = <<-SEQ
|
|
|
|
m(a) { |c| ... }
|
|
|
|
m(a, b) { |c, d| ... }
|
|
|
|
SEQ
|
|
|
|
m.comment = 'Stuff with +a+, yields +c+ for you to do stuff with'
|
|
|
|
c.add_method m
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
@s.coverage_level = 1
|
|
|
|
report = @s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
expected =
|
|
|
|
doc(
|
|
|
|
para('The following items are not documented:'),
|
|
|
|
blank_line,
|
|
|
|
verb(
|
|
|
|
"class C # is documented\n",
|
|
|
|
"\n",
|
|
|
|
" # in file file.rb\n",
|
|
|
|
" # +b+, +d+ is not documented\n",
|
|
|
|
" def m; end\n",
|
|
|
|
"\n",
|
|
|
|
"end\n"),
|
|
|
|
blank_line)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
assert_equal expected, report
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_summary
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
m = @tl.add_module RDoc::NormalModule, 'M'
|
|
|
|
m.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
a = RDoc::Attr.new nil, 'a', 'RW', nil
|
2012-11-27 08:28:14 +04:00
|
|
|
a.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_attribute a
|
|
|
|
|
|
|
|
c_c = RDoc::Constant.new 'C', nil, nil
|
2012-11-27 08:28:14 +04:00
|
|
|
c_c.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_constant c_c
|
|
|
|
|
|
|
|
m = RDoc::AnyMethod.new nil, 'm'
|
2012-11-27 08:28:14 +04:00
|
|
|
m.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
c.add_method m
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
summary = @s.summary.accept to_rdoc
|
|
|
|
summary.sub!(/ Elapsed:.*/m, '')
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
expected = <<-EXPECTED
|
2013-09-19 03:33:36 +04:00
|
|
|
Files: 0
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
Classes: 1 (1 undocumented)
|
|
|
|
Modules: 1 (1 undocumented)
|
|
|
|
Constants: 1 (1 undocumented)
|
|
|
|
Attributes: 1 (1 undocumented)
|
|
|
|
Methods: 1 (1 undocumented)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
Total: 5 (5 undocumented)
|
|
|
|
0.00% documented
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
assert_equal summary, expected
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_summary_level_false
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
@s.coverage_level = false
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
summary = @s.summary.accept to_rdoc
|
|
|
|
summary.sub!(/ Elapsed:.*/m, '')
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
expected = <<-EXPECTED
|
2013-09-19 03:33:36 +04:00
|
|
|
Files: 0
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
Classes: 1 (1 undocumented)
|
|
|
|
Modules: 0 (0 undocumented)
|
|
|
|
Constants: 0 (0 undocumented)
|
|
|
|
Attributes: 0 (0 undocumented)
|
|
|
|
Methods: 0 (0 undocumented)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
Total: 1 (1 undocumented)
|
|
|
|
0.00% documented
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
assert_equal summary, expected
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_summary_level_1
|
2012-11-27 08:28:14 +04:00
|
|
|
c = @tl.add_class RDoc::NormalClass, 'C'
|
|
|
|
c.record_location @tl
|
|
|
|
c.add_comment 'C', @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
m = RDoc::AnyMethod.new nil, 'm'
|
2012-11-27 08:28:14 +04:00
|
|
|
m.record_location @tl
|
2011-02-02 03:32:30 +03:00
|
|
|
m.params = '(p1, p2)'
|
|
|
|
m.comment = 'Stuff with +p1+'
|
|
|
|
c.add_method m
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
@store.complete :public
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
@s.coverage_level = 1
|
|
|
|
@s.report
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
summary = @s.summary.accept to_rdoc
|
|
|
|
summary.sub!(/ Elapsed:.*/m, '')
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
expected = <<-EXPECTED
|
2013-09-19 03:33:36 +04:00
|
|
|
Files: 0
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
Classes: 1 (0 undocumented)
|
|
|
|
Modules: 0 (0 undocumented)
|
|
|
|
Constants: 0 (0 undocumented)
|
|
|
|
Attributes: 0 (0 undocumented)
|
|
|
|
Methods: 1 (0 undocumented)
|
|
|
|
Parameters: 2 (1 undocumented)
|
2011-02-02 03:32:30 +03:00
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
Total: 4 (1 undocumented)
|
|
|
|
75.00% documented
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
assert_equal summary, expected
|
|
|
|
end
|
|
|
|
|
2013-09-19 03:33:36 +04:00
|
|
|
def to_rdoc
|
|
|
|
RDoc::Markup::ToRdoc.new
|
|
|
|
end
|
|
|
|
|
2014-12-07 04:22:37 +03:00
|
|
|
def test_undoc_params
|
|
|
|
method = RDoc::AnyMethod.new [], 'm'
|
|
|
|
method.params = '(a)'
|
|
|
|
method.comment = comment 'comment'
|
|
|
|
|
|
|
|
total, undoc = @s.undoc_params method
|
|
|
|
|
|
|
|
assert_equal 1, total
|
|
|
|
assert_equal %w[a], undoc
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_undoc_params_block
|
|
|
|
method = RDoc::AnyMethod.new [], 'm'
|
|
|
|
method.params = '(&a)'
|
|
|
|
method.comment = comment '+a+'
|
|
|
|
|
|
|
|
total, undoc = @s.undoc_params method
|
|
|
|
|
|
|
|
assert_equal 1, total
|
|
|
|
assert_empty undoc
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_undoc_params_documented
|
|
|
|
method = RDoc::AnyMethod.new [], 'm'
|
|
|
|
method.params = '(a)'
|
|
|
|
method.comment = comment '+a+'
|
|
|
|
|
|
|
|
total, undoc = @s.undoc_params method
|
|
|
|
|
|
|
|
assert_equal 1, total
|
|
|
|
assert_empty undoc
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_undoc_params_keywords
|
|
|
|
method = RDoc::AnyMethod.new [], 'm'
|
|
|
|
method.params = '(**a)'
|
|
|
|
method.comment = comment '+a+'
|
|
|
|
|
|
|
|
total, undoc = @s.undoc_params method
|
|
|
|
|
|
|
|
assert_equal 1, total
|
|
|
|
assert_empty undoc
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_undoc_params_splat
|
|
|
|
method = RDoc::AnyMethod.new [], 'm'
|
|
|
|
method.params = '(*a)'
|
|
|
|
method.comment = comment '+a+'
|
|
|
|
|
|
|
|
total, undoc = @s.undoc_params method
|
|
|
|
|
|
|
|
assert_equal 1, total
|
|
|
|
assert_empty undoc
|
|
|
|
end
|
|
|
|
|
2010-12-29 01:08:56 +03:00
|
|
|
end
|
|
|
|
|