Fixed more disabled tests

This commit is contained in:
Torsten Rüger 2019-08-13 11:14:36 +03:00
parent aaf169ad8d
commit 8036b23593
10 changed files with 59 additions and 56 deletions

View File

@ -89,6 +89,7 @@ module RubyX
# transform stored vool to target code
# return a linker
def to_target(platform)
raise "No platform given" unless platform
collection = to_risc
collection.translate(platform)
end
@ -133,9 +134,7 @@ module RubyX
compiler = RubyXCompiler.new(options)
compiler.load_parfait if options[:load_parfait]
compiler.ruby_to_vool(ruby)
platform = options[:platform]
raise "No platform given" unless platform
compiler.to_binary(platform)
compiler.to_binary(options[:platform])
end
end
end

View File

@ -12,11 +12,11 @@ module Risc
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot]
end
def pest_local_assign_instructions
def test_local_assign_instructions
assert_nil msg = check_nil , msg
end
def pest_constant_load
def test_constant_load
produced = produce_body
load = produced.next(8)
assert_equal LoadConstant , load.class

View File

@ -14,10 +14,10 @@ module Risc
Label]
end
def pest_send_instructions
def test_send_instructions
assert_nil msg = check_nil , msg
end
def pest_load_5
def test_load_5
produced = produce_body
assert_equal LoadConstant , produced.next(8).class
assert_equal 5 , produced.next(8).constant.value
@ -25,47 +25,47 @@ module Risc
def base
11
end
def pest_load_arg_const
def test_load_arg_const
produced = produce_body
assert_load( produced.next(base) , Parfait::Integer )
assert_equal 1 , produced.next(base).constant.value
end
def pest_load_next_m
def test_load_next_m
produced = produce_body.next(base+1)
assert_slot_to_reg( produced ,:r0 ,1 , :r2 )
end
def pest_load_args
def test_load_args
produced = produce_body.next(base+2)
assert_slot_to_reg( produced ,:r2 ,8 , :r2 )
end
def pest_store_arg_at
def test_store_arg_at
produced = produce_body.next(base+3)
assert_reg_to_slot( produced ,:r1 ,:r2 , 1 )
end
def pest_load_label
def test_load_label
produced = produce_body.next(base+4)
assert_load( produced , Label )
end
def pest_load_some
def test_load_some
produced = produce_body.next(base+5)
assert_slot_to_reg( produced ,:r0 ,1 , :r2 )
end
def pest_store_
def test_store_
produced = produce_body.next(base+6)
assert_reg_to_slot( produced ,:r1 ,:r2 , 4 )
end
def pest_swap_messages
def test_swap_messages
produced = produce_body.next(base+7)
assert_slot_to_reg( produced ,:r0 ,1 , :r0 )
end
def pest_function_call
def test_function_call
produced = produce_body
assert_equal FunctionCall , produced.next(base+8).class
assert_equal :get_internal_word , produced.next(base+8).method.name
end
def pest_check_continue
def test_check_continue
produced = produce_body
assert produced.next(base+9).name.start_with?("continue_")
end

View File

@ -14,15 +14,15 @@ module Risc
SlotToReg, SlotToReg, RegToSlot, Branch]
end
def pest_return_instructions
def test_return_instructions
assert_nil msg = check_nil , msg
end
def pest_function_return
def test_function_return
produced = produce_body.next(23)
assert_equal Branch , produced.class
assert_equal "return_label" , produced.label.name
end
def pest_load_5
def test_load_5
produced = produce_body.next(8)
assert_equal LoadConstant , produced.class
assert_equal 5 , produced.constant.value

View File

@ -14,14 +14,16 @@ module RubyX
def test_to_risc
assert_equal Risc::RiscCollection , @collection.class
end
def pest_linker
def test_linker
assert_equal Risc::Linker , @collection.translate(:interpreter).class
end
def pest_method
assert_equal :main , @linker.assemblers.first.callable.name
def test_method
linker = @collection.translate(:interpreter)
assert_equal :main , linker.assemblers.first.callable.name
end
def pest_asm_len
assert_equal 23 , @linker.assemblers.length
def test_asm_len
linker = @collection.translate(:interpreter)
assert_equal 22 , linker.assemblers.length
end
end
class TestRubyXCompilerParfait < MiniTest::Test
@ -30,11 +32,14 @@ module RubyX
def setup
super
#BETTER TEST for class method in VOOL
code = "class Space ; def self.class_method; return 1; end;def main(arg);return Space.class_method;end; end"
@comp = RubyXCompiler.ruby_to_binary(code , load_parfait: true , platform: :interpreter)
end
def pest_load
def test_load
object = Parfait.object_space.get_class_by_name(:Object)
assert_equal Parfait::Class , object.class
object = object.instance_type

View File

@ -13,7 +13,7 @@ module RubyX
options.delete(:platform)
assert_raises{ RubyXCompiler.ruby_to_binary(space_source_for("main"), options)}
end
def pest_return_linker
def test_return_linker
@linker = RubyXCompiler.ruby_to_binary(space_source_for("main"), RubyX.interpreter_test_options)
assert_equal Risc::Linker , @linker.class
end
@ -29,13 +29,13 @@ module RubyX
assert_equal Vool::ScopeStatement , compiler.vool.class
assert_equal 2 , compiler.vool.length
end
def pest_bin_two_sources
def test_bin_two_sources
compiler = RubyXCompiler.new(RubyX.default_test_options)
compiler.ruby_to_vool(space_source_for("main"))
compiler.ruby_to_vool(space_source_for("twain"))
linker = compiler.to_binary(:interpreter)
assert_equal Risc::Linker , linker.class
assert_equal 24 , linker.assemblers.length
assert_equal 23 , linker.assemblers.length
end
end
end

View File

@ -2,26 +2,25 @@ require_relative "helper"
module VoolBlocks
class TestConditionIfMom < MiniTest::Test
include MomCompile
include Mom
include VoolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
#Risc::Builtin.boot_functions
Mom::Builtin.boot_functions
@ins = compile_first_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
end
def pest_condition
def test_condition
assert_equal TruthCheck , @ins.next(4).class
end
def pest_condition_is_slot
def test_condition_is_slot
assert_equal SlotDefinition , @ins.next(4).condition.class , @ins
end
def pest_hoisted_dynamic_call
def test_hoisted_dynamic_call
assert_equal SimpleCall , @ins.next(2).class
assert_equal :div4 , @ins.next(2).method.name
end
def pest_array
def test_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, TruthCheck, Label ,
SlotLoad, Jump, Label, SlotLoad, Label] , @ins
end

View File

@ -6,23 +6,24 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
Risc::Builtin.boot_functions
@ins = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
@compiler = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
@ins = @compiler.mom_instructions.next
end
def pest_condition
def test_condition
assert_equal TruthCheck , @ins.next(4).class
end
def pest_condition_is_slot
def test_condition_is_slot
assert_equal SlotDefinition , @ins.next(4).condition.class , @ins
end
def pest_hoisted_dynamic_call
def test_hoisted_dynamic_call
assert_equal SimpleCall , @ins.next(2).class
assert_equal :div4 , @ins.next(2).method.name
end
def pest_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, TruthCheck, Label ,
SlotLoad, Jump, Label, SlotLoad, Label] , @ins
def test_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, TruthCheck,
Label ,SlotLoad, Jump, Label, SlotLoad, Label,
Label, ReturnSequence, Label ] , @ins
end
end

View File

@ -43,16 +43,16 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
Risc.boot!
@compiler = compile_first_method( "return 5.div4")
@ins = @compiler.mom_instructions.next
end
def pest_return_is_last
assert_equal ReturnJump , @ins.last.class
def test_return_is_last
assert_equal ReturnJump , @ins.next(5).class
end
def pest_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,SlotLoad,ReturnJump] , @ins
def test_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
SlotLoad,ReturnJump, Label, ReturnSequence, Label] , @ins
end
end
end

View File

@ -7,31 +7,30 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
Risc::Builtin.boot_functions
@compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end")
@ins = @compiler.mom_instructions.next
end
def pest_condition_compiles_to_check
def test_condition_compiles_to_check
assert_equal TruthCheck , @ins.next(5).class
end
def pest_condition_is_slot
def test_condition_is_slot
assert_equal SlotDefinition , @ins.next(5).condition.class , @ins
end
def pest_hoisetd
def test_hoisetd
jump = @ins.next(9)
assert_kind_of Jump , jump
assert jump.label.name.start_with?("cond_label") , jump.label.name
end
def pest_label
def test_label
label = @ins
assert_equal Label , label.class
assert label.name.start_with?("cond_label") , label.name
end
def pest_array
def test_array
check_array [Label, MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad ,
TruthCheck, MessageSetup, ArgumentTransfer, SimpleCall, Jump ,
Label] , @ins
Label, Label, ReturnSequence, Label] , @ins
end
end