diff --git a/lib/repl_type_completor/types.rb b/lib/repl_type_completor/types.rb index c002284..9984c24 100644 --- a/lib/repl_type_completor/types.rb +++ b/lib/repl_type_completor/types.rb @@ -162,7 +162,7 @@ def initialize(module_or_class) end def transform() = yield(self) def methods() = @module_or_class.methods - def all_methods() = methods | Kernel.methods + def all_methods() = methods | @module_or_class.private_methods def constants() = @module_or_class.constants def types() = [self] def nillable?() = false diff --git a/test/repl_type_completor/test_types.rb b/test/repl_type_completor/test_types.rb index 642b2dd..fadf14f 100644 --- a/test/repl_type_completor/test_types.rb +++ b/test/repl_type_completor/test_types.rb @@ -66,16 +66,30 @@ def foobar; end private def foobaz; end end String.define_method(:foobarbaz) {} - targets = [:foobar, :foobaz, :foobarbaz] + targets = [:foobar, :foobaz, :foobarbaz, :rand] type = ReplTypeCompletor::Types.type_from_object s assert_equal [:foobar, :foobarbaz], targets & type.methods - assert_equal [:foobar, :foobaz, :foobarbaz], targets & type.all_methods + assert_equal [:foobar, :foobaz, :foobarbaz, :rand], targets & type.all_methods assert_equal [:foobarbaz], targets & ReplTypeCompletor::Types::STRING.methods - assert_equal [:foobarbaz], targets & ReplTypeCompletor::Types::STRING.all_methods + assert_equal [:foobarbaz, :rand], targets & ReplTypeCompletor::Types::STRING.all_methods ensure String.remove_method :foobarbaz end + def test_singleton_type_methods + m = Module.new do + class << self + def foobar; end + private def foobaz; end + end + end + type = ReplTypeCompletor::Types::SingletonType.new(m) + assert_include type.methods, :foobar + assert_not_include type.methods, :foobaz + assert_include type.all_methods, :foobaz + assert_include type.all_methods, :rand + end + def test_basic_object_methods bo = BasicObject.new def bo.foobar; end