let helper output correct version in case of error

This commit is contained in:
Torsten Ruger 2015-11-02 20:11:40 +02:00
parent 45bd4bfdc6
commit 7eebc775d6

View File

@ -16,14 +16,22 @@ module Statements
def compare_instructions instruction , expect def compare_instructions instruction , expect
index = 0 index = 0
start = instruction
begin begin
should = expect[index] should = expect[index]
assert should , "No instruction at #{index}" assert should , "No instruction at #{index}"
assert_equal instruction.class , should , "Expected at #{index+1}" assert_equal instruction.class , should , "Expected at #{index+1}\n#{should(start)}"
index += 1 index += 1
instruction = instruction.next instruction = instruction.next
end while( instruction ) end while( instruction )
end end
def should start
str = start.to_ac.to_s
str.gsub!("Register::","")
ret = ""
str.split(",").each_slice(7).each do |line|
ret += " " + line.join(",") + " ,\n"
end
ret
end
end end