File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -396,6 +396,12 @@ class C # line 7 empty class
396396 }
397397 end
398398
399+ def hexdump ( bin )
400+ bin . unpack1 ( "H*" ) . gsub ( /.{1,32}/ ) { |s |
401+ "#{ '%04x:' % $~. begin ( 0 ) } #{ s . gsub ( /../ , " \\ &" ) . tap { |_ |_ [ 24 ] &&="-" } } \n "
402+ }
403+ end
404+
399405 def assert_iseq_to_binary ( code , mesg = nil )
400406 skip "does not work on other than x86" unless /x(?:86|64)|i\d 86/ =~ RUBY_PLATFORM
401407 iseq = RubyVM ::InstructionSequence . compile ( code )
@@ -406,10 +412,13 @@ def assert_iseq_to_binary(code, mesg = nil)
406412 raise
407413 end
408414 10 . times do
409- assert_equal ( bin , iseq . to_binary , mesg )
415+ bin2 = iseq . to_binary
416+ assert_equal ( bin , bin2 , message ( mesg ) { diff hexdump ( bin ) , hexdump ( bin2 ) } )
410417 end
411418 iseq2 = RubyVM ::InstructionSequence . load_from_binary ( bin )
412- assert_equal ( iseq . to_a , iseq2 . to_a , mesg )
419+ a1 = iseq . to_a
420+ a2 = iseq2 . to_a
421+ assert_equal ( a1 , a2 , message ( mesg ) { diff iseq . disassemble , iseq2 . disassemble } )
413422 iseq2
414423 end
415424
You can’t perform that action at this time.
0 commit comments