Skip to content

Commit cc383a9

Browse files
committed
Add one more test for overloading
1 parent 414572b commit cc383a9

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

test/fixtures/simple/lib/broken.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,25 @@ def params_also_in_overloads(user_options = {})
224224
# @option user_options [Number] :xid an alias to transaction_id.
225225
def params_only_in_overloads(user_options = {})
226226
end
227+
228+
# Tests that the default signature can be present as an overload tag.
229+
#
230+
# @overload params_only_in_overloads()
231+
# @example
232+
# Hello.new
233+
#
234+
# @overload params_only_in_overloads(transaction_id)
235+
# @example
236+
# Hello.new(123)
237+
#
238+
# @example
239+
# Hello.new(transaction_id: 123)
240+
# Hello.new(xid: 123)
241+
# @param [Hash] user_options the options to create a message with.
242+
# @option user_options [Number] :transaction_id
243+
# @option user_options [Number] :xid an alias to transaction_id.
244+
def one_param_missing_in_overload(user_options = {})
245+
end
227246
end
228247

229248
module YardError

test/test_helper.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
Bundler.require
88
require 'inch'
99

10+
def assert_roles(object, expected, unexpected)
11+
roles = object.roles.map(&:class)
12+
unexpected.each do |role|
13+
refute roles.include?(role), "Should not assign #{role}"
14+
end
15+
expected.each do |role|
16+
assert roles.include?(role), "Should assign #{role}"
17+
end
18+
end
19+
1020
def fixture_path(name)
1121
File.join(File.dirname(__FILE__), "fixtures", name.to_s)
1222
end

test/unit/code_object/proxy/method_object_test.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,23 @@ def test_overloading_with_bad_doc
295295

296296
def test_overloading_with_bad_doc
297297
m = @objects.find("Overloading#params_only_in_overloads")
298-
roles = m.roles.map(&:class)
299-
bad_roles = [
298+
unexpected_roles = [
300299
Inch::Evaluation::Role::Object::WithoutCodeExample,
301300
Inch::Evaluation::Role::MethodParameter::WithoutMention,
302301
Inch::Evaluation::Role::MethodParameter::WithoutType,
303302
]
304-
bad_roles.each do |role|
305-
refute roles.include?(role), "Should not assign #{role}"
306-
end
303+
assert_roles m, [], unexpected_roles
304+
end
305+
306+
def test_overloading_with_half_bad_doc
307+
m = @objects.find("Overloading#one_param_missing_in_overload")
308+
unexpected_roles = [
309+
Inch::Evaluation::Role::Object::WithoutCodeExample,
310+
]
311+
expected_roles = [
312+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
313+
Inch::Evaluation::Role::MethodParameter::WithoutType,
314+
]
315+
assert_roles m, expected_roles, unexpected_roles
307316
end
308317
end

0 commit comments

Comments
 (0)