diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-07 03:48:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-07 03:48:45 +0000 |
commit | 2de68923da346a150263ea50b8cb6ba87ebdde7a (patch) | |
tree | 8e8e75ac97299c0285fbb1110ff1011b5dbe99a3 /test | |
parent | eaf5e34b70eed584530ddbce0c44b53ae73f1a81 (diff) | |
download | ruby-2de68923da346a150263ea50b8cb6ba87ebdde7a.tar.gz |
test/ruby/test_iseq.rb: hexdump to diff
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_iseq.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index 2c8acb6421..cbd6e01c9b 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -396,6 +396,12 @@ class TestISeq < Test::Unit::TestCase } 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 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 |