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

ruby-changes:50903

From: nobu <ko1@a...>
Date: Sat, 7 Apr 2018 12:48:50 +0900 (JST)
Subject: [ruby-changes:50903] nobu:r63110 (trunk): test/ruby/test_iseq.rb: hexdump to diff

nobu	2018-04-07 12:48:45 +0900 (Sat, 07 Apr 2018)

  New Revision: 63110

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63110

  Log:
    test/ruby/test_iseq.rb: hexdump to diff

  Modified files:
    trunk/test/ruby/test_iseq.rb
Index: test/ruby/test_iseq.rb
===================================================================
--- test/ruby/test_iseq.rb	(revision 63109)
+++ test/ruby/test_iseq.rb	(revision 63110)
@@ -396,6 +396,12 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L396
     }
   end
 
+  def hexdump(bin)
+    bin.unpack1("H*").gsub(/.{1,32}/) {|s|
+      "#{'%04x:' % $~.begin(0)}#{s.gsub(/../, " \\&").tap{|_|_[24]&&="-"}}\n"
+    }
+  end
+
   def assert_iseq_to_binary(code, mesg = nil)
     skip "does not work on other than x86" unless /x(?:86|64)|i\d86/ =~ RUBY_PLATFORM
     iseq = RubyVM::InstructionSequence.compile(code)
@@ -406,10 +412,13 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L412
       raise
     end
     10.times do
-      assert_equal(bin, iseq.to_binary, mesg)
+      bin2 = iseq.to_binary
+      assert_equal(bin, bin2, message(mesg) {diff hexdump(bin), hexdump(bin2)})
     end
     iseq2 = RubyVM::InstructionSequence.load_from_binary(bin)
-    assert_equal(iseq.to_a, iseq2.to_a, mesg)
+    a1 = iseq.to_a
+    a2 = iseq2.to_a
+    assert_equal(a1, a2, message(mesg) {diff iseq.disassemble, iseq2.disassemble})
     iseq2
   end
 

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

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