framework for parfait runtime testing

with interpreter for now
later with arm exec support
This commit is contained in:
Torsten Ruger 2015-11-07 17:37:41 +02:00
parent 708cdace17
commit d878ce00d8
4 changed files with 43 additions and 2 deletions

View File

@ -14,7 +14,6 @@ module Register
include Collector
def initialize
@parser = Parser::Salama.new
@objects = {}
@booted = false
@constants = []
@ -70,7 +69,7 @@ module Register
end
def parse_and_compile bytes
syntax = @parser.parse_with_debug(bytes)
syntax = Parser::Salama.new.parse_with_debug(bytes)
parts = Parser::Transform.new.apply(syntax)
#puts parts.inspect
Soml.compile( parts )

39
test/parfait/helper.rb Normal file
View File

@ -0,0 +1,39 @@
require_relative '../helper'
require "interpreter/interpreter"
module RuntimeTests
def setup
@stdout = ""
end
def main
<<HERE
class Object
int main()
PROGRAM
end
end
HERE
end
def check
machine = Register.machine.boot
Soml::Compiler.load_parfait
machine.parse_and_compile main.sub("PROGRAM" , @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 @stdout , @interpreter.stdout
end
def check_return val
check
assert_equal Parfait::Message , @interpreter.get_register(:r1).class
assert_equal val , @interpreter.get_register(:r1).return_value
end
end

1
test/parfait/test_all.rb Normal file
View File

@ -0,0 +1 @@
require_relative "test_layout"

View File

@ -4,6 +4,8 @@ require_relative "elf/test_all"
require_relative "parfait_ruby/test_all"
require_relative "parfait/test_all"
require_relative "register/test_all"
require_relative "interpreter/test_all"