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

View File

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

View File

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

View File

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

View File

@ -14,14 +14,16 @@ module RubyX
def test_to_risc def test_to_risc
assert_equal Risc::RiscCollection , @collection.class assert_equal Risc::RiscCollection , @collection.class
end end
def pest_linker def test_linker
assert_equal Risc::Linker , @collection.translate(:interpreter).class assert_equal Risc::Linker , @collection.translate(:interpreter).class
end end
def pest_method def test_method
assert_equal :main , @linker.assemblers.first.callable.name linker = @collection.translate(:interpreter)
assert_equal :main , linker.assemblers.first.callable.name
end end
def pest_asm_len def test_asm_len
assert_equal 23 , @linker.assemblers.length linker = @collection.translate(:interpreter)
assert_equal 22 , linker.assemblers.length
end end
end end
class TestRubyXCompilerParfait < MiniTest::Test class TestRubyXCompilerParfait < MiniTest::Test
@ -30,11 +32,14 @@ module RubyX
def setup def setup
super 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" 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) @comp = RubyXCompiler.ruby_to_binary(code , load_parfait: true , platform: :interpreter)
end end
def pest_load def test_load
object = Parfait.object_space.get_class_by_name(:Object) object = Parfait.object_space.get_class_by_name(:Object)
assert_equal Parfait::Class , object.class assert_equal Parfait::Class , object.class
object = object.instance_type object = object.instance_type

View File

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

View File

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

View File

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

View File

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

View File

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