mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/irb] Regroup completion tests
https://github.com/ruby/irb/commit/71631287c8
This commit is contained in:
parent
83a9b91522
commit
3e18bb916f
1 changed files with 117 additions and 113 deletions
|
@ -77,44 +77,7 @@ module TestIRB
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_complete_symbol
|
class TestRequireComepletion < TestCompletion
|
||||||
%w"UTF-16LE UTF-7".each do |enc|
|
|
||||||
"K".force_encoding(enc).to_sym
|
|
||||||
rescue
|
|
||||||
end
|
|
||||||
_ = :aiueo
|
|
||||||
assert_include(IRB::InputCompletor.retrieve_completion_data(":a", bind: binding), ":aiueo")
|
|
||||||
assert_empty(IRB::InputCompletor.retrieve_completion_data(":irb_unknown_symbol_abcdefg", bind: binding))
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_complete_invalid_three_colons
|
|
||||||
assert_empty(IRB::InputCompletor.retrieve_completion_data(":::A", bind: binding))
|
|
||||||
assert_empty(IRB::InputCompletor.retrieve_completion_data(":::", bind: binding))
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_complete_absolute_constants_with_special_characters
|
|
||||||
assert_empty(IRB::InputCompletor.retrieve_completion_data("::A:", bind: binding))
|
|
||||||
assert_empty(IRB::InputCompletor.retrieve_completion_data("::A.", bind: binding))
|
|
||||||
assert_empty(IRB::InputCompletor.retrieve_completion_data("::A(", bind: binding))
|
|
||||||
assert_empty(IRB::InputCompletor.retrieve_completion_data("::A)", bind: binding))
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_complete_symbol_failure
|
|
||||||
assert_nil(IRB::InputCompletor::PerfectMatchedProc.(":aiueo", bind: binding))
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_complete_reserved_words
|
|
||||||
candidates = IRB::InputCompletor.retrieve_completion_data("de", bind: binding)
|
|
||||||
%w[def defined?].each do |word|
|
|
||||||
assert_include candidates, word
|
|
||||||
end
|
|
||||||
|
|
||||||
candidates = IRB::InputCompletor.retrieve_completion_data("__", bind: binding)
|
|
||||||
%w[__ENCODING__ __LINE__ __FILE__].each do |word|
|
|
||||||
assert_include candidates, word
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_complete_require
|
def test_complete_require
|
||||||
candidates = IRB::InputCompletor::CompletionProc.("'irb", "require ", "")
|
candidates = IRB::InputCompletor::CompletionProc.("'irb", "require ", "")
|
||||||
%w['irb/init 'irb/ruby-lex].each do |word|
|
%w['irb/init 'irb/ruby-lex].each do |word|
|
||||||
|
@ -187,7 +150,9 @@ module TestIRB
|
||||||
assert_include candidates, word
|
assert_include candidates, word
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class TestVariableCompletion < TestCompletion
|
||||||
def test_complete_variable
|
def test_complete_variable
|
||||||
# Bug fix issues https://github.com/ruby/irb/issues/368
|
# Bug fix issues https://github.com/ruby/irb/issues/368
|
||||||
# Variables other than `str_example` and `@str_example` are defined to ensure that irb completion does not cause unintended behavior
|
# Variables other than `str_example` and `@str_example` are defined to ensure that irb completion does not cause unintended behavior
|
||||||
|
@ -217,6 +182,56 @@ module TestIRB
|
||||||
assert_equal(IRB::InputCompletor.retrieve_completion_data("@str_example.to_s", bind: binding, doc_namespace: true), "String.to_s")
|
assert_equal(IRB::InputCompletor.retrieve_completion_data("@str_example.to_s", bind: binding, doc_namespace: true), "String.to_s")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_complete_sort_variables
|
||||||
|
xzy, xzy_1, xzy2 = '', '', ''
|
||||||
|
|
||||||
|
xzy.clear
|
||||||
|
xzy_1.clear
|
||||||
|
xzy2.clear
|
||||||
|
|
||||||
|
candidates = IRB::InputCompletor.retrieve_completion_data("xz", bind: binding, doc_namespace: false)
|
||||||
|
assert_equal(candidates, %w[xzy xzy2 xzy_1])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_complete_symbol
|
||||||
|
%w"UTF-16LE UTF-7".each do |enc|
|
||||||
|
"K".force_encoding(enc).to_sym
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
_ = :aiueo
|
||||||
|
assert_include(IRB::InputCompletor.retrieve_completion_data(":a", bind: binding), ":aiueo")
|
||||||
|
assert_empty(IRB::InputCompletor.retrieve_completion_data(":irb_unknown_symbol_abcdefg", bind: binding))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_complete_invalid_three_colons
|
||||||
|
assert_empty(IRB::InputCompletor.retrieve_completion_data(":::A", bind: binding))
|
||||||
|
assert_empty(IRB::InputCompletor.retrieve_completion_data(":::", bind: binding))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_complete_absolute_constants_with_special_characters
|
||||||
|
assert_empty(IRB::InputCompletor.retrieve_completion_data("::A:", bind: binding))
|
||||||
|
assert_empty(IRB::InputCompletor.retrieve_completion_data("::A.", bind: binding))
|
||||||
|
assert_empty(IRB::InputCompletor.retrieve_completion_data("::A(", bind: binding))
|
||||||
|
assert_empty(IRB::InputCompletor.retrieve_completion_data("::A)", bind: binding))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_complete_symbol_failure
|
||||||
|
assert_nil(IRB::InputCompletor::PerfectMatchedProc.(":aiueo", bind: binding))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_complete_reserved_words
|
||||||
|
candidates = IRB::InputCompletor.retrieve_completion_data("de", bind: binding)
|
||||||
|
%w[def defined?].each do |word|
|
||||||
|
assert_include candidates, word
|
||||||
|
end
|
||||||
|
|
||||||
|
candidates = IRB::InputCompletor.retrieve_completion_data("__", bind: binding)
|
||||||
|
%w[__ENCODING__ __LINE__ __FILE__].each do |word|
|
||||||
|
assert_include candidates, word
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_complete_methods
|
def test_complete_methods
|
||||||
obj = Object.new
|
obj = Object.new
|
||||||
obj.singleton_class.class_eval {
|
obj.singleton_class.class_eval {
|
||||||
|
@ -240,16 +255,5 @@ module TestIRB
|
||||||
assert_include(IRB::InputCompletor.retrieve_completion_data("private_hoge.to_s", bind: bind), "private_hoge.to_s")
|
assert_include(IRB::InputCompletor.retrieve_completion_data("private_hoge.to_s", bind: bind), "private_hoge.to_s")
|
||||||
assert_include(IRB::InputCompletor.retrieve_completion_data("private_hoge", bind: bind, doc_namespace: true), "private_hoge")
|
assert_include(IRB::InputCompletor.retrieve_completion_data("private_hoge", bind: bind, doc_namespace: true), "private_hoge")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_complete_sort_variables
|
|
||||||
xzy, xzy_1, xzy2 = '', '', ''
|
|
||||||
|
|
||||||
xzy.clear
|
|
||||||
xzy_1.clear
|
|
||||||
xzy2.clear
|
|
||||||
|
|
||||||
candidates = IRB::InputCompletor.retrieve_completion_data("xz", bind: binding, doc_namespace: false)
|
|
||||||
assert_equal(candidates, %w[xzy xzy2 xzy_1])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue