2015-10-14 20:49:05 +02:00
|
|
|
require_relative '../../helper'
|
2015-10-19 13:46:12 +02:00
|
|
|
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
|
|
|
|
|
2014-05-21 20:13:12 +02:00
|
|
|
|
2014-05-21 20:37:04 +02:00
|
|
|
|
2014-05-21 20:13:12 +02:00
|
|
|
module Fragments
|
|
|
|
|
2015-10-19 13:46:12 +02:00
|
|
|
def setup
|
|
|
|
@stdout = ""
|
|
|
|
end
|
2015-07-18 13:33:09 +02:00
|
|
|
def check
|
2015-10-09 20:53:22 +02:00
|
|
|
machine = Virtual.machine.boot
|
|
|
|
machine.parse_and_compile @string_input
|
2015-10-19 13:46:12 +02:00
|
|
|
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
|
2014-06-05 12:02:36 +02:00
|
|
|
end
|
2015-05-16 11:53:10 +02:00
|
|
|
|
2014-05-21 20:13:12 +02:00
|
|
|
end
|