diff options
author | tomoya ishida <[email protected]> | 2024-08-29 01:16:27 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-08-28 16:16:31 +0000 |
commit | ce6b0c44256fc10509263d92959150fcbaa63e21 (patch) | |
tree | 3f2cae92773e569dda2c2fe325e38bcb6ac8fdf4 /test | |
parent | ccef391140f924af907080e62f24ef259550f324 (diff) |
[ruby/irb] Colorize command input
(https://github.com/ruby/irb/pull/983)
https://github.com/ruby/irb/commit/0e64136e76
Diffstat (limited to 'test')
-rw-r--r-- | test/irb/test_input_method.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/irb/test_input_method.rb b/test/irb/test_input_method.rb index ce317b4b32..078631db8d 100644 --- a/test/irb/test_input_method.rb +++ b/test/irb/test_input_method.rb @@ -8,6 +8,7 @@ module TestIRB class InputMethodTest < TestCase def setup @conf_backup = IRB.conf.dup + IRB.init_config(nil) IRB.conf[:LC_MESSAGES] = IRB::Locale.new save_encodings end @@ -33,6 +34,21 @@ module TestIRB assert_not_nil Reline.dig_perfect_match_proc end + def test_colorize + original_colorable = IRB::Color.method(:colorable?) + IRB::Color.instance_eval { undef :colorable? } + IRB::Color.define_singleton_method(:colorable?) { true } + workspace = IRB::WorkSpace.new(binding) + input_method = IRB::RelineInputMethod.new(IRB::RegexpCompletor.new) + IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new(workspace, input_method).context + assert_equal "\e[1m$\e[0m\e[m", Reline.output_modifier_proc.call('$', complete: false) + assert_equal "\e[1m$\e[0m\e[m \e[34m\e[1m1\e[0m + \e[34m\e[1m2\e[0m", Reline.output_modifier_proc.call('$ 1 + 2', complete: false) + assert_equal "\e[32m\e[1m$a\e[0m", Reline.output_modifier_proc.call('$a', complete: false) + ensure + IRB::Color.instance_eval { undef :colorable? } + IRB::Color.define_singleton_method(:colorable?, original_colorable) + end + def test_initialization_without_use_autocomplete original_show_doc_proc = Reline.dialog_proc(:show_doc)&.dialog_proc empty_proc = Proc.new {} |