rubyx/test/compiler/expressions/code_checker.rb

18 lines
616 B
Ruby
Raw Normal View History

2015-09-27 10:27:30 +02:00
module CodeChecker
def check
2015-10-09 20:53:22 +02:00
machine = Virtual.machine.boot
machine.parse_and_compile @string_input
2015-09-27 10:27:30 +02:00
produced = Virtual.machine.space.get_main.source
assert @output , "No output given"
assert_equal @output.length , produced.blocks.length , "Block length"
produced.blocks.each_with_index do |b,i|
codes = @output[i]
assert codes , "No codes for block #{i}"
assert_equal b.codes.length , codes.length , "Code length for block #{i}"
b.codes.each_with_index do |c , ii |
assert_equal codes[ii] , c.class , "Block #{i} , code #{ii}"
end
end
end
end