Skip to content

Commit 45b427a

Browse files
committed
tests for find_superclass_method
1 parent 1b54b96 commit 45b427a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/test_rdoc_any_method.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,34 @@ def test_parent_name
244244
assert_equal 'C1', @c1.method_list.last.parent_name
245245
end
246246

247+
def test_find_superclass_method
248+
k3 = RDoc::NormalClass.new "RDoc::CodeObject", nil
249+
k2 = RDoc::NormalClass.new "RDoc::MethodAttr", k3
250+
k = RDoc::NormalClass.new "RDoc::AnyMethod", k2
251+
252+
m = RDoc::AnyMethod.new "def test_super", "test_super"
253+
m2 = RDoc::AnyMethod.new "def test_super", "test_super"
254+
m3 = RDoc::AnyMethod.new "def test_no_super", "test_no_super"
255+
256+
m.uses_superclass = true
257+
k.add_method m
258+
k.add_method m3
259+
260+
k2.add_method m2
261+
262+
assert_nil(m3.find_superclass_method, 'no superclass method for "test_no_super"')
263+
assert_equal(m2, m.find_superclass_method, 'superclass method found for "test_super"')
264+
265+
k2 = RDoc::NormalClass.new "RDoc::MethodAttr", k3
266+
k = RDoc::NormalClass.new "RDoc::AnyMethod", k2
267+
268+
m.uses_superclass = true
269+
k.add_method m
270+
k.add_method m3
271+
272+
k3.add_method m2
273+
274+
assert_equal(m2, m.find_superclass_method, 'superclass method found two levels up')
275+
end
247276
end
248277

0 commit comments

Comments
 (0)