inch 0.4.10 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -11
- data/Gemfile +2 -5
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/bin/inch +3 -3
- data/config/defaults.rb +0 -7
- data/inch.gemspec +7 -7
- data/lib/inch.rb +9 -9
- data/lib/inch/api.rb +10 -10
- data/lib/inch/api/compare.rb +2 -2
- data/lib/inch/api/compare/code_objects.rb +3 -2
- data/lib/inch/api/compare/codebases.rb +1 -1
- data/lib/inch/api/diff.rb +10 -7
- data/lib/inch/api/filter.rb +1 -1
- data/lib/inch/api/get.rb +1 -1
- data/lib/inch/api/options/base.rb +4 -4
- data/lib/inch/api/options/filter.rb +4 -0
- data/lib/inch/api/options/suggest.rb +5 -1
- data/lib/inch/api/stats.rb +1 -0
- data/lib/inch/api/suggest.rb +10 -9
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/arguments.rb +2 -2
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +4 -4
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +8 -7
- data/lib/inch/cli/command/inspect.rb +4 -5
- data/lib/inch/cli/command/list.rb +4 -4
- data/lib/inch/cli/command/options/base.rb +8 -8
- data/lib/inch/cli/command/options/base_list.rb +5 -9
- data/lib/inch/cli/command/options/console.rb +3 -4
- data/lib/inch/cli/command/options/diff.rb +6 -8
- data/lib/inch/cli/command/options/inspect.rb +2 -2
- data/lib/inch/cli/command/options/list.rb +2 -3
- data/lib/inch/cli/command/options/show.rb +2 -2
- data/lib/inch/cli/command/options/stats.rb +1 -2
- data/lib/inch/cli/command/options/suggest.rb +3 -6
- data/lib/inch/cli/command/output/base.rb +6 -4
- data/lib/inch/cli/command/output/console.rb +5 -4
- data/lib/inch/cli/command/output/diff.rb +6 -6
- data/lib/inch/cli/command/output/inspect.rb +8 -6
- data/lib/inch/cli/command/output/list.rb +1 -0
- data/lib/inch/cli/command/output/show.rb +5 -4
- data/lib/inch/cli/command/output/stats.rb +21 -21
- data/lib/inch/cli/command/output/suggest.rb +27 -30
- data/lib/inch/cli/command/show.rb +4 -4
- data/lib/inch/cli/command/stats.rb +4 -4
- data/lib/inch/cli/command/suggest.rb +6 -6
- data/lib/inch/cli/command_parser.rb +5 -6
- data/lib/inch/cli/sparkline_helper.rb +6 -6
- data/lib/inch/cli/trace_helper.rb +1 -1
- data/lib/inch/cli/yardopts_helper.rb +3 -4
- data/lib/inch/code_object.rb +3 -3
- data/lib/inch/code_object/converter.rb +8 -6
- data/lib/inch/code_object/provider.rb +1 -1
- data/lib/inch/code_object/provider/yard.rb +12 -10
- data/lib/inch/code_object/provider/yard/docstring.rb +19 -51
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +4 -4
- data/lib/inch/code_object/provider/yard/object.rb +10 -12
- data/lib/inch/code_object/provider/yard/object/base.rb +27 -48
- data/lib/inch/code_object/provider/yard/object/method_object.rb +10 -47
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +6 -10
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +8 -12
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +4 -1
- data/lib/inch/code_object/provider/yard/parser.rb +3 -3
- data/lib/inch/code_object/proxy.rb +9 -10
- data/lib/inch/code_object/proxy/base.rb +10 -12
- data/lib/inch/code_object/proxy/method_object.rb +2 -3
- data/lib/inch/code_object/proxy/method_parameter_object.rb +3 -5
- data/lib/inch/codebase.rb +5 -4
- data/lib/inch/codebase/objects_filter.rb +4 -2
- data/lib/inch/codebase/serializer.rb +3 -3
- data/lib/inch/config.rb +2 -2
- data/lib/inch/config/base.rb +1 -0
- data/lib/inch/config/codebase.rb +4 -4
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +15 -16
- data/lib/inch/evaluation/file.rb +1 -1
- data/lib/inch/evaluation/grade_list.rb +2 -2
- data/lib/inch/evaluation/object_schema.rb +1 -1
- data/lib/inch/evaluation/proxy.rb +7 -8
- data/lib/inch/evaluation/proxy/base.rb +10 -13
- data/lib/inch/evaluation/proxy/constant_object.rb +1 -1
- data/lib/inch/evaluation/proxy/method_object.rb +5 -12
- data/lib/inch/evaluation/proxy/module_object.rb +1 -1
- data/lib/inch/evaluation/proxy/namespace_object.rb +1 -1
- data/lib/inch/evaluation/role/base.rb +1 -1
- data/lib/inch/evaluation/role/method.rb +2 -2
- data/lib/inch/evaluation/role/method_parameter.rb +1 -2
- data/lib/inch/evaluation/role/object.rb +2 -2
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +2 -3
- data/lib/inch/utils/shell_helper.rb +1 -1
- data/lib/inch/utils/ui.rb +5 -5
- data/lib/inch/utils/weighted_list.rb +3 -2
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/simple/lib/broken.rb +7 -35
- data/test/fixtures/simple/lib/foo.rb +1 -22
- data/test/integration/api/compare/codebases.rb +1 -1
- data/test/integration/cli/command/console_test.rb +5 -5
- data/test/integration/cli/command/inspect_test.rb +5 -4
- data/test/integration/cli/command/list_test.rb +4 -3
- data/test/integration/cli/command/show_test.rb +4 -4
- data/test/integration/cli/command/stats_test.rb +2 -2
- data/test/integration/cli/command/suggest_test.rb +10 -10
- data/test/integration/stats_options_test.rb +3 -3
- data/test/integration/visibility_options_test.rb +13 -13
- data/test/shared/base_list.rb +3 -4
- data/test/test_helper.rb +6 -16
- data/test/unit/api/filter_test.rb +7 -7
- data/test/unit/api/get_test.rb +1 -1
- data/test/unit/api/list_test.rb +1 -1
- data/test/unit/api/options/base_test.rb +3 -3
- data/test/unit/api/stats_test.rb +1 -1
- data/test/unit/api/suggest_test.rb +3 -3
- data/test/unit/cli/arguments_test.rb +1 -1
- data/test/unit/cli/command/base_test.rb +1 -1
- data/test/unit/cli/command/options/base_list_test.rb +2 -2
- data/test/unit/cli/command/options/base_object_test.rb +1 -1
- data/test/unit/cli/command/options/base_test.rb +1 -1
- data/test/unit/cli/command_parser_test.rb +2 -2
- data/test/unit/cli/trace_helper_test.rb +1 -1
- data/test/unit/cli/yardopts_helper_test.rb +3 -4
- data/test/unit/code_object/converter_test.rb +1 -1
- data/test/unit/code_object/provider/yard/docstring_test.rb +28 -106
- data/test/unit/code_object/provider/yard/nodoc_helper_test.rb +5 -6
- data/test/unit/code_object/provider/yard/object/method_object_test.rb +10 -20
- data/test/unit/code_object/provider/yard_test.rb +4 -4
- data/test/unit/code_object/provider_test.rb +1 -1
- data/test/unit/code_object/proxy/method_object_test.rb +262 -382
- data/test/unit/code_object/proxy_test.rb +1 -1
- data/test/unit/codebase/objects_test.rb +2 -2
- data/test/unit/codebase/proxy_test.rb +1 -1
- data/test/unit/config/codebase_test.rb +1 -1
- data/test/unit/evaluation/role/base_test.rb +2 -2
- data/test/unit/utils/ui_test.rb +4 -4
- data/test/unit/utils/weighted_list_test.rb +4 -7
- metadata +4 -14
- data/.rubocop.yml +0 -15
- data/.rubocop_todo.yml +0 -94
- data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +0 -12
- data/lib/inch/code_object/proxy/class_variable_object.rb +0 -8
- data/lib/inch/evaluation/proxy/class_variable_object.rb +0 -19
- data/lib/inch/evaluation/role/class_variable.rb +0 -55
- data/test/fixtures/simple/lib/broken_ruby_2_0_features.rb +0 -7
- data/test/fixtures/simple/lib/directives.rb +0 -8
@@ -1,17 +1,14 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::CodeObject::Provider::YARD::Parser do
|
4
4
|
before do
|
5
5
|
@config = Inch::Config.codebase
|
6
|
-
@parser = ::Inch::CodeObject::Provider::YARD::Parser.parse(
|
7
|
-
fixture_path(:simple), @config)
|
6
|
+
@parser = ::Inch::CodeObject::Provider::YARD::Parser.parse(fixture_path(:simple), @config)
|
8
7
|
@objects = @parser.objects
|
9
8
|
end
|
10
9
|
|
11
10
|
it "should work for Overloading#params_also_in_overloads" do
|
12
|
-
m = @objects.
|
13
|
-
o.fullname == "Overloading#params_also_in_overloads"
|
14
|
-
end
|
11
|
+
m = @objects.detect { |o| o.fullname == 'Overloading#params_also_in_overloads' }
|
15
12
|
|
16
13
|
assert m.has_code_example?
|
17
14
|
|
@@ -19,8 +16,7 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
19
16
|
assert_equal 2, m.parameters.size # at this moment, this counts all parameters in all overloaded signatures
|
20
17
|
|
21
18
|
signature = m.signatures[0]
|
22
|
-
assert_equal "params_also_in_overloads(user_options = {})",
|
23
|
-
signature.signature
|
19
|
+
assert_equal "params_also_in_overloads(user_options = {})", signature.signature
|
24
20
|
assert_equal 1, signature.parameters.size
|
25
21
|
refute signature.parameter(:user_options).nil?
|
26
22
|
assert signature.has_code_example?
|
@@ -28,8 +24,7 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
28
24
|
|
29
25
|
signature = m.signatures[1]
|
30
26
|
assert_equal "params_also_in_overloads()", signature.signature
|
31
|
-
assert signature.parameters.empty?,
|
32
|
-
"Should have been empty: #{signature.parameters.inspect}"
|
27
|
+
assert signature.parameters.empty?, "Should have been empty: #{signature.parameters.inspect}"
|
33
28
|
assert signature.has_code_example?
|
34
29
|
refute signature.has_doc?
|
35
30
|
|
@@ -42,9 +37,7 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
42
37
|
end
|
43
38
|
|
44
39
|
it "should work for Overloading#params_only_in_overloads" do
|
45
|
-
m = @objects.
|
46
|
-
o.fullname == "Overloading#params_only_in_overloads"
|
47
|
-
end
|
40
|
+
m = @objects.detect { |o| o.fullname == 'Overloading#params_only_in_overloads' }
|
48
41
|
|
49
42
|
assert m.has_code_example?
|
50
43
|
|
@@ -53,8 +46,7 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
53
46
|
|
54
47
|
signature = m.signatures[0]
|
55
48
|
assert_equal "params_only_in_overloads()", signature.signature
|
56
|
-
assert signature.parameters.empty?,
|
57
|
-
"Should have been empty: #{signature.parameters.inspect}"
|
49
|
+
assert signature.parameters.empty?, "Should have been empty: #{signature.parameters.inspect}"
|
58
50
|
assert signature.has_code_example?
|
59
51
|
refute signature.has_doc?
|
60
52
|
|
@@ -70,19 +62,17 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
70
62
|
assert_equal 1, signature.parameters.size
|
71
63
|
refute signature.parameter(:user_options).nil?
|
72
64
|
assert signature.has_code_example?
|
73
|
-
#
|
65
|
+
#assert signature.has_doc?
|
74
66
|
end
|
75
67
|
|
76
68
|
it "should work" do
|
77
|
-
m = @objects.
|
78
|
-
o.fullname == "Foo::Bar#method_with_unstructured_doc"
|
79
|
-
end
|
69
|
+
m = @objects.detect { |o| o.fullname == 'Foo::Bar#method_with_unstructured_doc' }
|
80
70
|
assert_equal 1, m.signatures.size
|
81
71
|
assert_equal 1, m.parameters.size
|
82
72
|
end
|
83
73
|
|
84
74
|
it "should work 2" do
|
85
|
-
m = @objects.
|
75
|
+
m = @objects.detect { |o| o.fullname == 'Foo#method_with_splat_parameter' }
|
86
76
|
assert_equal 1, m.signatures.size
|
87
77
|
assert_equal 1, m.parameters.size
|
88
78
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::CodeObject::Provider::YARD do
|
4
4
|
let(:described_class) { ::Inch::CodeObject::Provider::YARD }
|
@@ -12,14 +12,14 @@ describe ::Inch::CodeObject::Provider::YARD do
|
|
12
12
|
fullname = "Foo#b"
|
13
13
|
|
14
14
|
provider1 = described_class.parse(fixture_path(:diff1))
|
15
|
-
object1 = provider1.objects.
|
15
|
+
object1 = provider1.objects.detect { |o| o.fullname == fullname }
|
16
16
|
|
17
17
|
provider2 = described_class.parse(fixture_path(:diff2))
|
18
|
-
object2 = provider2.objects.
|
18
|
+
object2 = provider2.objects.detect { |o| o.fullname == fullname }
|
19
19
|
|
20
20
|
refute object1.nil?
|
21
21
|
refute object2.nil?
|
22
22
|
assert object1.object_id != object2.object_id
|
23
23
|
end
|
24
24
|
|
25
|
-
end
|
25
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::CodeObject::Proxy::MethodObject do
|
4
4
|
before do
|
@@ -6,55 +6,47 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
6
6
|
@objects = @codebase.objects
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
assert m.undocumented?
|
15
|
-
end
|
9
|
+
def test_transitive_tags_dont_matter
|
10
|
+
m = @objects.find("InchTest::Deprecated::ClassMethods")
|
11
|
+
assert_equal 0, m.score
|
12
|
+
assert m.undocumented?
|
13
|
+
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
def test_raising_method_with_comment
|
16
|
+
m = @objects.find("InchTest#raising_method_with_comment")
|
17
|
+
assert m.score > 0
|
18
|
+
refute m.undocumented?
|
19
|
+
end
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
def test_raising_method
|
22
|
+
m = @objects.find("InchTest#raising_method")
|
23
|
+
assert_equal 0, m.score
|
24
|
+
assert m.undocumented?
|
25
|
+
end
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
27
|
+
def test_yielding_method
|
28
|
+
m = @objects.find("InchTest#yielding_method")
|
29
|
+
assert_equal 0, m.score
|
30
|
+
assert m.undocumented?
|
34
31
|
end
|
35
32
|
|
36
|
-
|
37
|
-
#
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
m = @objects.find(fullname)
|
42
|
-
assert m.tagged_as_private?
|
43
|
-
end
|
33
|
+
def test_tagged_as_private
|
34
|
+
%w( InchTest#method_with_private_tag
|
35
|
+
InchTest#private_method_with_tomdoc).each do |fullname|
|
36
|
+
m = @objects.find(fullname)
|
37
|
+
assert m.tagged_as_private?
|
44
38
|
end
|
39
|
+
end
|
45
40
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
m = @objects.find(fullname)
|
52
|
-
assert m.tagged_as_internal_api?
|
53
|
-
end
|
41
|
+
def test_tagged_as_internal_api
|
42
|
+
%w( InchTest#private_api_with_yard
|
43
|
+
InchTest#internal_api_with_tomdoc).each do |fullname|
|
44
|
+
m = @objects.find(fullname)
|
45
|
+
assert m.tagged_as_internal_api?
|
54
46
|
end
|
55
47
|
end
|
56
48
|
|
57
|
-
|
49
|
+
def test_method_without_doc
|
58
50
|
m = @objects.find("Foo::Bar#method_without_doc")
|
59
51
|
refute m.has_doc?
|
60
52
|
refute m.has_parameters?
|
@@ -64,7 +56,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
64
56
|
assert_equal 0, m.score
|
65
57
|
end
|
66
58
|
|
67
|
-
|
59
|
+
def test_method_with_missing_param_doc
|
68
60
|
m = @objects.find("Foo::Bar#method_with_missing_param_doc")
|
69
61
|
assert m.has_doc?
|
70
62
|
assert m.has_parameters?
|
@@ -75,399 +67,287 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
75
67
|
assert p.mentioned?
|
76
68
|
p = m.parameter(:param2)
|
77
69
|
assert p.mentioned?
|
78
|
-
|
79
|
-
# not mentioned
|
80
70
|
p = m.parameter(:param3)
|
81
71
|
refute p.mentioned?
|
82
72
|
|
83
73
|
assert m.score
|
84
74
|
end
|
85
75
|
|
86
|
-
|
87
|
-
#
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
assert m.has_parameters?
|
92
|
-
assert m.return_mentioned?
|
93
|
-
|
94
|
-
assert m.score
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should handle YARD when only @return is given" do
|
98
|
-
m = @objects.find("Foo::Bar#method_without_params_or_docstring")
|
99
|
-
refute m.has_doc?
|
100
|
-
refute m.has_parameters?
|
101
|
-
assert m.return_mentioned?
|
102
|
-
refute m.return_described?
|
103
|
-
|
104
|
-
assert m.score
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should handle unusable return value when only @return [void] is given" do
|
108
|
-
m = @objects.find("Foo::Bar#method_without_usable_return_value")
|
109
|
-
assert m.return_mentioned?
|
110
|
-
assert m.return_described?
|
111
|
-
|
112
|
-
assert m.score
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should handle RDoc" do
|
116
|
-
m = @objects.find("Foo::Bar#method_with_rdoc_doc")
|
117
|
-
assert m.has_doc?
|
118
|
-
assert m.has_parameters?
|
119
|
-
p = m.parameter(:param1)
|
120
|
-
assert p.mentioned? # mentioned in docs, correctly
|
121
|
-
refute m.return_mentioned?
|
122
|
-
|
123
|
-
assert m.score
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should handle other RDoc styles" do
|
127
|
-
m = @objects.find("Foo::Bar#method_with_other_rdoc_doc")
|
128
|
-
assert m.has_doc?
|
129
|
-
assert m.has_parameters?
|
130
|
-
p = m.parameter(:param1)
|
131
|
-
assert p.mentioned? # mentioned in docs, correctly
|
132
|
-
p = m.parameter(:param2)
|
133
|
-
assert p.mentioned? # mentioned in docs, correctly
|
134
|
-
p = m.parameter(:param3)
|
135
|
-
assert p.mentioned? # mentioned in docs, correctly
|
136
|
-
refute m.return_mentioned?
|
137
|
-
|
138
|
-
assert m.score
|
139
|
-
end
|
76
|
+
def test_method_with_wrong_doc
|
77
|
+
m = @objects.find("Foo::Bar#method_with_wrong_doc")
|
78
|
+
assert m.has_doc?
|
79
|
+
assert m.has_parameters?
|
80
|
+
assert m.return_mentioned?
|
140
81
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
82
|
+
assert_equal 4, m.parameters.size
|
83
|
+
p = m.parameter(:param1)
|
84
|
+
assert p.mentioned? # mentioned in docs, correctly
|
85
|
+
refute p.wrongly_mentioned?
|
86
|
+
p = m.parameter(:param2)
|
87
|
+
refute p.mentioned?
|
88
|
+
refute p.wrongly_mentioned? # not mentioned in docs at all
|
89
|
+
p = m.parameter(:param3)
|
90
|
+
refute p.mentioned?
|
91
|
+
refute p.wrongly_mentioned? # not mentioned in docs at all
|
92
|
+
p = m.parameter(:param4)
|
93
|
+
assert p.mentioned?
|
94
|
+
assert p.wrongly_mentioned? # mentioned in docs, but not present
|
149
95
|
|
150
|
-
|
151
|
-
|
96
|
+
assert m.score
|
97
|
+
end
|
152
98
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
assert p.mentioned? # mentioned in docs, correctly
|
159
|
-
refute m.return_mentioned?
|
99
|
+
def test_method_with_full_doc
|
100
|
+
m = @objects.find("Foo::Bar#method_with_full_doc")
|
101
|
+
assert m.has_doc?
|
102
|
+
assert m.has_parameters?
|
103
|
+
assert m.return_mentioned?
|
160
104
|
|
161
|
-
|
105
|
+
assert_equal 2, m.parameters.size
|
106
|
+
m.parameters.each do |param|
|
107
|
+
assert param.mentioned?
|
108
|
+
assert param.typed?
|
109
|
+
assert param.described?
|
110
|
+
refute param.wrongly_mentioned?
|
162
111
|
end
|
163
112
|
|
164
|
-
|
165
|
-
|
166
|
-
assert m.has_doc?
|
167
|
-
assert m.has_parameters?
|
168
|
-
p = m.parameter(:format)
|
169
|
-
refute p.mentioned? # mentioned in docs, correctly
|
170
|
-
refute m.return_mentioned?
|
171
|
-
|
172
|
-
assert m.score
|
173
|
-
end
|
113
|
+
assert_equal 100, m.score
|
114
|
+
end
|
174
115
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
refute m.return_mentioned?
|
116
|
+
def test_method_without_params_or_return_type
|
117
|
+
m = @objects.find("Foo::Bar#method_without_params_or_return_type")
|
118
|
+
assert m.has_doc?
|
119
|
+
refute m.has_parameters?
|
120
|
+
refute m.return_mentioned?
|
181
121
|
|
182
|
-
|
183
|
-
end
|
122
|
+
assert m.score
|
184
123
|
end
|
185
124
|
|
186
|
-
|
125
|
+
def test_method_without_docstring
|
126
|
+
m = @objects.find("Foo::Bar#method_without_docstring")
|
127
|
+
refute m.has_doc?
|
128
|
+
assert m.has_parameters?
|
129
|
+
assert m.return_mentioned?
|
187
130
|
|
188
|
-
|
189
|
-
|
190
|
-
assert m.getter?, "should be a getter"
|
191
|
-
refute m.setter?
|
192
|
-
refute m.has_doc?
|
193
|
-
assert_equal 0, m.score
|
194
|
-
end
|
131
|
+
assert m.score
|
132
|
+
end
|
195
133
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
assert_equal 0, m.score
|
202
|
-
end
|
134
|
+
def test_method_without_params_or_docstring
|
135
|
+
m = @objects.find("Foo::Bar#method_without_params_or_docstring")
|
136
|
+
refute m.has_doc?
|
137
|
+
refute m.has_parameters?
|
138
|
+
assert m.return_mentioned?
|
203
139
|
|
204
|
-
|
205
|
-
|
206
|
-
refute m.getter?
|
207
|
-
assert m.setter?, "should be a setter"
|
208
|
-
refute m.has_doc?
|
209
|
-
assert_equal 0, m.score
|
210
|
-
end
|
140
|
+
assert m.score
|
141
|
+
end
|
211
142
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
143
|
+
def test_method_with_rdoc_doc
|
144
|
+
m = @objects.find("Foo::Bar#method_with_rdoc_doc")
|
145
|
+
assert m.has_doc?
|
146
|
+
assert m.has_parameters?
|
147
|
+
p = m.parameter(:param1)
|
148
|
+
assert p.mentioned? # mentioned in docs, correctly
|
149
|
+
refute m.return_mentioned?
|
219
150
|
|
220
|
-
|
221
|
-
|
222
|
-
refute m.getter?
|
223
|
-
assert m.setter?, "should be a setter"
|
224
|
-
refute m.has_doc?
|
225
|
-
assert_equal 0, m.score
|
226
|
-
end
|
151
|
+
assert m.score
|
152
|
+
end
|
227
153
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
154
|
+
def test_method_with_other_rdoc_doc
|
155
|
+
m = @objects.find("Foo::Bar#method_with_other_rdoc_doc")
|
156
|
+
assert m.has_doc?
|
157
|
+
assert m.has_parameters?
|
158
|
+
p = m.parameter(:param1)
|
159
|
+
assert p.mentioned? # mentioned in docs, correctly
|
160
|
+
p = m.parameter(:param2)
|
161
|
+
assert p.mentioned? # mentioned in docs, correctly
|
162
|
+
p = m.parameter(:param3)
|
163
|
+
assert p.mentioned? # mentioned in docs, correctly
|
164
|
+
refute m.return_mentioned?
|
236
165
|
|
237
|
-
|
238
|
-
|
239
|
-
m = @objects.find("InchTest#attr_getset=")
|
240
|
-
refute m.getter?
|
241
|
-
assert m.setter?, "should be a setter"
|
242
|
-
refute m.has_doc?
|
243
|
-
assert_equal 0, m.score
|
244
|
-
end
|
166
|
+
assert m.score
|
167
|
+
end
|
245
168
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
169
|
+
def test_method_with_unstructured_doc
|
170
|
+
m = @objects.find("Foo::Bar#method_with_unstructured_doc")
|
171
|
+
assert m.has_doc?
|
172
|
+
assert m.has_parameters?
|
173
|
+
p = m.parameter(:param1)
|
174
|
+
assert p.mentioned? # mentioned in docs, correctly
|
175
|
+
refute m.return_mentioned?
|
253
176
|
|
254
|
-
|
255
|
-
|
256
|
-
refute m.getter?
|
257
|
-
assert m.setter?, "should be a setter"
|
258
|
-
refute m.has_doc?
|
259
|
-
assert_equal 0, m.score
|
260
|
-
end
|
177
|
+
assert m.score
|
178
|
+
end
|
261
179
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
180
|
+
def test_method_with_unstructured_doc_missing_params
|
181
|
+
m = @objects.find("Foo::Bar#method_with_unstructured_doc_missing_params")
|
182
|
+
assert m.has_doc?
|
183
|
+
assert m.has_parameters?
|
184
|
+
p = m.parameter(:format)
|
185
|
+
refute p.mentioned? # mentioned in docs, correctly
|
186
|
+
refute m.return_mentioned?
|
268
187
|
|
269
|
-
|
270
|
-
|
271
|
-
m = @objects.find("Attributes#username=")
|
272
|
-
refute_equal 0, m.score
|
273
|
-
refute m.undocumented?
|
274
|
-
end
|
188
|
+
assert m.score
|
189
|
+
end
|
275
190
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
m2 = @objects.find("Foo#method_with_splat_parameter2")
|
281
|
-
assert_equal 1, m1.parameters.size
|
282
|
-
assert_equal 1, m2.parameters.size
|
283
|
-
assert_equal m1.score, m2.score
|
284
|
-
end
|
191
|
+
def test_question_mark_method
|
192
|
+
m = @objects.find("InchTest#question_mark_method?")
|
193
|
+
refute m.has_doc?
|
194
|
+
refute m.has_parameters?
|
285
195
|
|
286
|
-
|
287
|
-
m1 = @objects.find("InchTest#_aliased_method")
|
288
|
-
m2 = @objects.find("InchTest#_alias_method")
|
289
|
-
assert_equal m1.score, m2.score
|
290
|
-
end
|
196
|
+
assert_equal 0, m.score
|
291
197
|
end
|
292
198
|
|
293
|
-
|
294
|
-
#
|
295
|
-
|
296
|
-
|
297
|
-
refute_equal 0, m.score
|
298
|
-
refute m.undocumented?
|
299
|
-
end
|
199
|
+
def test_question_mark_method_with_description
|
200
|
+
m = @objects.find("InchTest#question_mark_method_with_description?")
|
201
|
+
refute m.has_doc?
|
202
|
+
refute m.has_parameters?
|
300
203
|
|
301
|
-
|
302
|
-
|
303
|
-
refute_equal 0, m.score
|
304
|
-
# refute m.undocumented?
|
305
|
-
# NOTE: this is undocumented since there is no original_docstring
|
306
|
-
end
|
204
|
+
assert m.score > 0
|
205
|
+
assert m.score >= 50 # TODO: don't use magic numbers
|
307
206
|
end
|
308
207
|
|
309
|
-
|
310
|
-
#
|
311
|
-
|
312
|
-
|
313
|
-
list << @objects.find("Overloading#rgb")
|
314
|
-
list << @objects.find("Overloading#rgba")
|
315
|
-
list << @objects.find("Overloading#change_color")
|
316
|
-
list << @objects.find("Overloading#mix")
|
317
|
-
list << @objects.find("Overloading#hooks")
|
318
|
-
list << @objects.find("Overloading#identifiers")
|
319
|
-
list << @objects.find("Overloading#params_only_in_overloads")
|
320
|
-
list.each do |m|
|
321
|
-
assert_equal 100, m.score, "#{m.fullname} did not get 100"
|
322
|
-
end
|
323
|
-
end
|
208
|
+
def test_method_with_description_and_parameters
|
209
|
+
m = @objects.find("InchTest#method_with_description_and_parameters?")
|
210
|
+
refute m.has_doc?
|
211
|
+
assert m.has_parameters?
|
324
212
|
|
325
|
-
|
326
|
-
|
327
|
-
refute m.has_doc? # it may be mentioned in the docs, but it's malformed.
|
328
|
-
end
|
213
|
+
assert m.score > 0
|
214
|
+
end
|
329
215
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
m, Inch::Evaluation::Role::MethodParameter::WithoutMention, "block")
|
339
|
-
end
|
216
|
+
def test_depth
|
217
|
+
m = @objects.find("#root_method")
|
218
|
+
assert_equal 1, m.depth
|
219
|
+
m = @objects.find("InchTest#getter")
|
220
|
+
assert_equal 2, m.depth
|
221
|
+
m = @objects.find("Foo::Bar#method_without_doc")
|
222
|
+
assert_equal 3, m.depth
|
223
|
+
end
|
340
224
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
]
|
349
|
-
assert_roles m, [], unexpected_roles
|
350
|
-
end
|
225
|
+
def test_getter
|
226
|
+
m = @objects.find("InchTest#getter")
|
227
|
+
assert m.getter?, "should be a getter"
|
228
|
+
refute m.setter?
|
229
|
+
refute m.has_doc?
|
230
|
+
assert_equal 0, m.score
|
231
|
+
end
|
351
232
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
359
|
-
Inch::Evaluation::Role::MethodParameter::WithoutType
|
360
|
-
]
|
361
|
-
assert_roles m, expected_roles, unexpected_roles
|
362
|
-
end
|
233
|
+
def test_setter
|
234
|
+
m = @objects.find("InchTest#attr_setter=")
|
235
|
+
refute m.getter?
|
236
|
+
assert m.setter?, "should be a setter"
|
237
|
+
refute m.has_doc?
|
238
|
+
assert_equal 0, m.score
|
363
239
|
end
|
364
240
|
|
365
|
-
|
366
|
-
#
|
367
|
-
|
368
|
-
|
241
|
+
def test_setter2
|
242
|
+
m = @objects.find("InchTest#manual_setter=")
|
243
|
+
refute m.getter?
|
244
|
+
assert m.setter?, "should be a setter"
|
245
|
+
refute m.has_doc?
|
246
|
+
assert_equal 0, m.score
|
247
|
+
end
|
369
248
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
249
|
+
def test_manual_getset
|
250
|
+
m = @objects.find("InchTest#manual_getset")
|
251
|
+
assert m.getter?, "should be a getter"
|
252
|
+
refute m.setter?
|
253
|
+
refute m.has_doc?
|
254
|
+
assert_equal 0, m.score
|
255
|
+
end
|
377
256
|
|
378
|
-
|
379
|
-
|
257
|
+
def test_manual_getset2
|
258
|
+
m = @objects.find("InchTest#manual_getset=")
|
259
|
+
refute m.getter?
|
260
|
+
assert m.setter?, "should be a setter"
|
261
|
+
refute m.has_doc?
|
262
|
+
assert_equal 0, m.score
|
263
|
+
end
|
380
264
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
265
|
+
def test_attr_getset
|
266
|
+
m = @objects.find("InchTest#attr_getset")
|
267
|
+
assert m.getter?, "should be a getter"
|
268
|
+
refute m.setter?
|
269
|
+
refute m.has_doc?
|
270
|
+
assert_equal 0, m.score
|
271
|
+
end
|
388
272
|
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
p = m.parameter(:param1)
|
397
|
-
assert p.mentioned? # mentioned in docs, correctly
|
398
|
-
refute p.wrongly_mentioned?
|
399
|
-
p = m.parameter(:param2)
|
400
|
-
refute p.mentioned?
|
401
|
-
refute p.wrongly_mentioned? # not mentioned in docs at all
|
402
|
-
p = m.parameter(:param3)
|
403
|
-
refute p.mentioned?
|
404
|
-
refute p.wrongly_mentioned? # not mentioned in docs at all
|
405
|
-
|
406
|
-
p = m.parameter(:param4)
|
407
|
-
assert p.mentioned?
|
408
|
-
assert p.wrongly_mentioned? # mentioned in docs, but not present
|
409
|
-
|
410
|
-
assert m.score
|
411
|
-
end
|
273
|
+
def test_attr_getset2
|
274
|
+
m = @objects.find("InchTest#attr_getset=")
|
275
|
+
refute m.getter?
|
276
|
+
assert m.setter?, "should be a setter"
|
277
|
+
refute m.has_doc?
|
278
|
+
assert_equal 0, m.score
|
279
|
+
end
|
412
280
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
m.parameters.each do |param|
|
421
|
-
assert param.mentioned?
|
422
|
-
assert param.typed?
|
423
|
-
assert param.described?
|
424
|
-
refute param.wrongly_mentioned?
|
425
|
-
end
|
426
|
-
|
427
|
-
assert_equal 100, m.score
|
428
|
-
end
|
281
|
+
def test_struct_getset
|
282
|
+
m = @objects.find("InchTest::StructGetSet#struct_getset")
|
283
|
+
assert m.getter?, "should be a getter"
|
284
|
+
refute m.setter?
|
285
|
+
refute m.has_doc?
|
286
|
+
assert_equal 0, m.score
|
287
|
+
end
|
429
288
|
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
289
|
+
def test_struct_getset2
|
290
|
+
m = @objects.find("InchTest::StructGetSet#struct_getset=")
|
291
|
+
refute m.getter?
|
292
|
+
assert m.setter?, "should be a setter"
|
293
|
+
refute m.has_doc?
|
294
|
+
assert_equal 0, m.score
|
295
|
+
end
|
434
296
|
|
435
|
-
|
436
|
-
|
437
|
-
|
297
|
+
def test_splat_parameter_notation
|
298
|
+
# it should assign the same score whether the parameter is
|
299
|
+
# described with or without the splat (*) operator
|
300
|
+
m1 = @objects.find("Foo#method_with_splat_parameter")
|
301
|
+
m2 = @objects.find("Foo#method_with_splat_parameter2")
|
302
|
+
assert_equal 1, m1.parameters.size
|
303
|
+
assert_equal 1, m2.parameters.size
|
304
|
+
assert_equal m1.score, m2.score
|
305
|
+
end
|
438
306
|
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
307
|
+
def test_alias_method
|
308
|
+
m1 = @objects.find("InchTest#_aliased_method")
|
309
|
+
m2 = @objects.find("InchTest#_alias_method")
|
310
|
+
assert_equal m1.score, m2.score
|
311
|
+
end
|
443
312
|
|
444
|
-
|
445
|
-
|
313
|
+
def test_overloading1
|
314
|
+
list = []
|
315
|
+
list << @objects.find("Overloading#rgb")
|
316
|
+
list << @objects.find("Overloading#rgba")
|
317
|
+
list << @objects.find("Overloading#change_color")
|
318
|
+
list << @objects.find("Overloading#mix")
|
319
|
+
list << @objects.find("Overloading#hooks")
|
320
|
+
list << @objects.find("Overloading#identifiers")
|
321
|
+
list << @objects.find("Overloading#params_only_in_overloads")
|
322
|
+
list.each do |m|
|
323
|
+
assert_equal 100, m.score, "#{m.fullname} did not get 100"
|
446
324
|
end
|
325
|
+
end
|
447
326
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
assert m.has_parameters?
|
453
|
-
|
454
|
-
assert m.score > 0
|
455
|
-
end
|
327
|
+
def test_overloading_with_bad_doc
|
328
|
+
m = @objects.find("Overloading#missing_param_names")
|
329
|
+
refute m.has_doc? # it may be mentioned in the docs, but it's malformed.
|
330
|
+
end
|
456
331
|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
332
|
+
def test_overloading_with_bad_doc
|
333
|
+
m = @objects.find("Overloading#params_only_in_overloads")
|
334
|
+
unexpected_roles = [
|
335
|
+
Inch::Evaluation::Role::Object::WithoutCodeExample,
|
336
|
+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
337
|
+
Inch::Evaluation::Role::MethodParameter::WithoutType,
|
338
|
+
]
|
339
|
+
assert_roles m, [], unexpected_roles
|
340
|
+
end
|
465
341
|
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
342
|
+
def test_overloading_with_half_bad_doc
|
343
|
+
m = @objects.find("Overloading#one_param_missing_in_overload")
|
344
|
+
unexpected_roles = [
|
345
|
+
Inch::Evaluation::Role::Object::WithoutCodeExample,
|
346
|
+
]
|
347
|
+
expected_roles = [
|
348
|
+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
349
|
+
Inch::Evaluation::Role::MethodParameter::WithoutType,
|
350
|
+
]
|
351
|
+
assert_roles m, expected_roles, unexpected_roles
|
472
352
|
end
|
473
353
|
end
|