rubyx/test/compiler/fragments/helper.rb
Torsten Ruger bdcd0f297d first interpreted tests, fix branch issues
whole branch logic wobbly
better syntax needed, but working(ish) for now
2015-10-19 14:46:12 +03:00

32 lines
703 B
Ruby

require_relative '../../helper'
require "interpreter/interpreter"
# Fragments are small programs that we run through the interpreter and really only check
# - the no. of instructions processed
# - the stdout output
module Fragments
def setup
@stdout = ""
end
def check
machine = Virtual.machine.boot
machine.parse_and_compile @string_input
machine.collect
interpreter = Interpreter::Interpreter.new
interpreter.start machine.init
count = 0
begin
count += 1
#puts interpreter.instruction
interpreter.tick
end while( ! interpreter.instruction.nil?)
assert_equal @length , count
assert_equal @stdout , interpreter.stdout
end
end