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
|
2015-10-15 12:08:53 +02:00
|
|
|
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"
|
2015-10-23 20:27:36 +02:00
|
|
|
#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
|