[前][次][番号順一覧][スレッド一覧]

ruby-changes:55555

From: Takashi <ko1@a...>
Date: Sat, 27 Apr 2019 22:02:30 +0900 (JST)
Subject: [ruby-changes:55555] Takashi Kokubun:9348643575 (trunk): make sync-default-gems GEM=irb

https://git.ruby-lang.org/ruby.git/commit/?id=9348643575

From 9348643575d7a744f3e404d9069a0d29f97960a0 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Sat, 27 Apr 2019 22:01:10 +0900
Subject: make sync-default-gems GEM=irb

Synced from https://github.com/ruby/irb/commit/5feb361ed80736efa5b2c2b629837ec2a5fc2cdb.
This includes a support to colorize named Class instance on IRB inspect.

diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index 2e7a3e8..201aeca 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -46,6 +46,10 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L46
       end
 
       def inspect_colorable?(obj)
+        if obj.is_a?(Class) && obj.name
+          return true
+        end
+
         case obj
         when Hash
           obj.all? { |k, v| inspect_colorable?(k) && inspect_colorable?(v) }
diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb
index 8439fd5..8a59374 100644
--- a/test/irb/test_color.rb
+++ b/test/irb/test_color.rb
@@ -30,7 +30,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L30
         "# comment" => "#{BLUE}#{BOLD}# comment#{CLEAR}",
         "yield(hello)" => "#{GREEN}yield#{CLEAR}(hello)",
       }.each do |code, result|
-        assert_equal(result, with_term { IRB::Color.colorize_code(code) })
+        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')
@@ -54,10 +54,11 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L54
         { a: 4 } => true,
         /reg/ => true,
         Object.new => false,
+        Struct => true,
         Struct.new(:a) => false,
         Struct.new(:a).new(1) => false,
       }.each do |object, result|
-        assert_equal(result, IRB::Color.inspect_colorable?(object))
+        assert_equal(result, IRB::Color.inspect_colorable?(object), "Case: inspect_colorable?(#{object.inspect})")
       end
     end
 
diff --git a/test/irb/test_completion.rb b/test/irb/test_completion.rb
index 608c41b..83df9c1 100644
--- a/test/irb/test_completion.rb
+++ b/test/irb/test_completion.rb
@@ -7,7 +7,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_completion.rb#L7
       begin
         require "irb/completion"
         bug5938 = '[ruby-core:42244]'
-        cmds = %W[-rirb -rirb/completion -e IRB.setup(__FILE__)
+        cmds = %W[-W0 -rirb -rirb/completion -e IRB.setup(__FILE__)
          -e IRB.conf[:MAIN_CONTEXT]=IRB::Irb.new.context
          -e module\sFoo;def\sself.name;//;end;end
          -e IRB::InputCompletor::CompletionProc.call("[1].first.")
diff --git a/test/irb/test_option.rb b/test/irb/test_option.rb
index 85ebd08..6f36d81 100644
--- a/test/irb/test_option.rb
+++ b/test/irb/test_option.rb
@@ -5,7 +5,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_option.rb#L5
   class TestOption < Test::Unit::TestCase
     def test_end_of_option
       bug4117 = '[ruby-core:33574]'
-      status = assert_in_out_err(%w[-rirb -e IRB.start(__FILE__) -- -f --], "", //, [], bug4117)
+      status = assert_in_out_err(%w[-W0 -rirb -e IRB.start(__FILE__) -- -f --], "", //, [], bug4117)
       assert(status.success?, bug4117)
     end
   end
diff --git a/test/irb/test_raise_no_backtrace_exception.rb b/test/irb/test_raise_no_backtrace_exception.rb
index 1d2e05b..38c61f2 100644
--- a/test/irb/test_raise_no_backtrace_exception.rb
+++ b/test/irb/test_raise_no_backtrace_exception.rb
@@ -4,7 +4,7 @@ require 'test/unit' https://github.com/ruby/ruby/blob/trunk/test/irb/test_raise_no_backtrace_exception.rb#L4
 module TestIRB
   class TestRaiseNoBacktraceException < Test::Unit::TestCase
     def test_raise_exception
-      assert_in_out_err(%w[-rirb -W1 -e IRB.start(__FILE__) -- -f --], <<-IRB, /Exception: foo/, [])
+      assert_in_out_err(%w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, /Exception: foo/, [])
       e = Exception.new("foo")
       def e.backtrace; nil; end
       raise e
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]