rubyx/test/compiler/statements/helper.rb

30 lines
802 B
Ruby
Raw Normal View History

2015-10-15 08:47:11 +02:00
require_relative '../../helper'
module Statements
def check
2015-10-22 17:16:29 +02:00
machine = Register.machine
machine.boot unless machine.booted
2015-10-15 08:47:11 +02:00
machine.parse_and_compile @string_input
2015-10-22 17:16:29 +02:00
produced = Register.machine.space.get_main.source
2015-10-15 08:47:11 +02:00
assert @expect , "No output given"
#assert_equal @expect.length , produced.instructions.length , "instructions length #{produced.instructions.to_ac}"
compare_instructions produced.instructions , @expect
produced.instructions
end
def compare_instructions instruction , expect
index = 0
begin
should = expect[index]
assert should , "No instruction at #{index}"
assert_equal instruction.class , should , "Expected at #{index+1}"
index += 1
instruction = instruction.next
end while( instruction )
2015-10-15 08:47:11 +02:00
end
end