ruby-changes:55577
From: Takashi <ko1@a...>
Date: Sun, 28 Apr 2019 20:19:38 +0900 (JST)
Subject: [ruby-changes:55577] Takashi Kokubun:588f212c26 (trunk): make sync-default-gems GEM=irb
https://git.ruby-lang.org/ruby.git/commit/?id=588f212c26 From 588f212c2665555f76c68e0954332619bff60418 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Sun, 28 Apr 2019 20:18:44 +0900 Subject: make sync-default-gems GEM=irb from https://github.com/ruby/irb/commit/44301d382794d91e2caa16dd4efe62439e0041d8. This includes some fixes for string interpolation highlight fixes. diff --git a/lib/irb/color.rb b/lib/irb/color.rb index 87f6d88..aec66cd 100644 --- a/lib/irb/color.rb +++ b/lib/irb/color.rb @@ -22,7 +22,8 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L22 on_CHAR: [[BLUE, BOLD], [Ripper::EXPR_END]], on_const: [[BLUE, BOLD, UNDERLINE], [Ripper::EXPR_ARG, Ripper::EXPR_CMDARG]], on_embexpr_beg: [[RED], [Ripper::EXPR_BEG, Ripper::EXPR_END]], - on_embexpr_end: [[RED], [Ripper::EXPR_END, Ripper::EXPR_ENDFN]], + on_embexpr_end: [[RED], [Ripper::EXPR_END, Ripper::EXPR_ENDFN, Ripper::EXPR_CMDARG]], + on_embvar: [[RED], [Ripper::EXPR_BEG]], on_ident: [[BLUE, BOLD], [Ripper::EXPR_ENDFN]], on_int: [[BLUE, BOLD], [Ripper::EXPR_END]], on_float: [[MAGENTA, BOLD], [Ripper::EXPR_END]], @@ -33,7 +34,7 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L34 on_regexp_end: [[RED, BOLD], [Ripper::EXPR_BEG]], on_symbeg: [[BLUE, BOLD], [Ripper::EXPR_FNAME]], on_tstring_beg: [[RED], [Ripper::EXPR_BEG, Ripper::EXPR_END, Ripper::EXPR_ARG, Ripper::EXPR_CMDARG]], - on_tstring_content: [[RED], [Ripper::EXPR_BEG, Ripper::EXPR_ARG, Ripper::EXPR_CMDARG]], + on_tstring_content: [[RED], [Ripper::EXPR_BEG, Ripper::EXPR_END, Ripper::EXPR_ARG, Ripper::EXPR_CMDARG]], on_tstring_end: [[RED], [Ripper::EXPR_END]], } rescue NameError diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb index cf09f85..5a20448 100644 --- a/test/irb/test_color.rb +++ b/test/irb/test_color.rb @@ -29,21 +29,17 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L29 'ERB.new("a#{nil}b", trim_mode: "-")' => "#{BLUE}#{BOLD}#{UNDERLINE}ERB#{CLEAR}.new(#{RED}\"#{CLEAR}#{RED}a#{CLEAR}#{RED}\#{#{CLEAR}#{CYAN}#{BOLD}nil#{CLEAR}#{RED}}#{CLEAR}#{RED}b#{CLEAR}#{RED}\"#{CLEAR}, #{MAGENTA}trim_mode:#{CLEAR} #{RED}\"#{CLEAR}#{RED}-#{CLEAR}#{RED}\"#{CLEAR})", "# comment" => "#{BLUE}#{BOLD}# comment#{CLEAR}", "yield(hello)" => "#{GREEN}yield#{CLEAR}(hello)", - }.each do |code, result| + '"##@var]"' => "#{RED}\"#{CLEAR}#{RED}##{CLEAR}#{RED}##{CLEAR}@var#{RED}]#{CLEAR}#{RED}\"#{CLEAR}", + '"foo#{a} #{b}"' => "#{RED}\"#{CLEAR}#{RED}foo#{CLEAR}#{RED}\#{#{CLEAR}a#{RED}}#{CLEAR}#{RED} #{CLEAR}#{RED}\#{#{CLEAR}b#{RED}}#{CLEAR}#{RED}\"#{CLEAR}", + }.merge!( + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0') + { '/r#{e}g/' => "#{RED}\e[1m/#{CLEAR}#{RED}r#{CLEAR}#{RED}\#{#{CLEAR}e#{RED}}#{CLEAR}#{RED}g#{CLEAR}#{RED}\e[1m/#{CLEAR}" } + else + { '/r#{e}g/' => "#{RED}#{BOLD}/#{CLEAR}#{RED}r#{CLEAR}#{RED}\#{#{CLEAR}e#{RED}}#{CLEAR}#{RED}g#{CLEAR}#{RED}#{BOLD}/#{CLEAR}" } + end + ).each do |code, result| assert_equal(result, with_term { IRB::Color.colorize_code(code) }, "Case: colorize_code(#{code.dump})") end - - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0') - { - '/r#{e}g/' => "#{RED}#{BOLD}/#{CLEAR}#{RED}r#{CLEAR}#{RED}\#{#{CLEAR}e}#{RED}g#{CLEAR}#{RED}#{BOLD}/#{CLEAR}", - } - else - { - '/r#{e}g/' => "#{RED}#{BOLD}/#{CLEAR}#{RED}r#{CLEAR}#{RED}\#{#{CLEAR}e#{RED}}#{CLEAR}#{RED}g#{CLEAR}#{RED}#{BOLD}/#{CLEAR}", - } - end.each do |code, result| - assert_equal(result, with_term { IRB::Color.colorize_code(code) }) - end end def test_inspect_colorable -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/