Skip to content

Commit 4340279

Browse files
committed
Add test for scan visibility count
In class, public and private methods are counted separately in this test.
1 parent 27a9c41 commit 4340279

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/test_rdoc_parser_ruby.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,6 +3277,33 @@ def b() end
32773277
assert c_b.singleton
32783278
end
32793279

3280+
def test_scan_visibility_count
3281+
util_parser <<-RUBY
3282+
class C < Original::Base
3283+
class C2 < Original::Base
3284+
def m0() end
3285+
def m1() end
3286+
3287+
private
3288+
3289+
def m2() end
3290+
def m3() end
3291+
def m4() end
3292+
end
3293+
end
3294+
RUBY
3295+
3296+
@parser.scan
3297+
3298+
c = @store.find_class_named 'C::C2'
3299+
3300+
private_method_count = c.method_list.count { |m| :private == m.visibility }
3301+
assert_equal 3, private_method_count
3302+
3303+
public_method_count = c.method_list.count { |m| :public == m.visibility }
3304+
assert_equal 2, public_method_count
3305+
end
3306+
32803307
def test_singleton_method_via_eigenclass
32813308
util_parser <<-RUBY
32823309
class C

0 commit comments

Comments
 (0)