From 8036b23593f88e3148045561475eed7988eb76eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20R=C3=BCger?= Date: Tue, 13 Aug 2019 11:14:36 +0300 Subject: [PATCH] Fixed more disabled tests --- lib/rubyx/rubyx_compiler.rb | 5 ++--- test/mom/assign/test_assign_local_send.rb | 4 ++-- test/mom/send/test_send_simple_args.rb | 24 +++++++++++------------ test/mom/test_return_call.rb | 6 +++--- test/rubyx/test_rubyx_compiler2.rb | 17 ++++++++++------ test/rubyx/test_rubyx_compiler3.rb | 6 +++--- test/vool/blocks/test_if_condition.rb | 13 ++++++------ test/vool/test_if_condition.rb | 17 ++++++++-------- test/vool/test_return.rb | 10 +++++----- test/vool/test_while_statement1.rb | 13 ++++++------ 10 files changed, 59 insertions(+), 56 deletions(-) diff --git a/lib/rubyx/rubyx_compiler.rb b/lib/rubyx/rubyx_compiler.rb index b41bf585..564dbf33 100644 --- a/lib/rubyx/rubyx_compiler.rb +++ b/lib/rubyx/rubyx_compiler.rb @@ -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 diff --git a/test/mom/assign/test_assign_local_send.rb b/test/mom/assign/test_assign_local_send.rb index f9df4efb..a12e1003 100644 --- a/test/mom/assign/test_assign_local_send.rb +++ b/test/mom/assign/test_assign_local_send.rb @@ -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 diff --git a/test/mom/send/test_send_simple_args.rb b/test/mom/send/test_send_simple_args.rb index 27624572..bfafde3a 100644 --- a/test/mom/send/test_send_simple_args.rb +++ b/test/mom/send/test_send_simple_args.rb @@ -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 diff --git a/test/mom/test_return_call.rb b/test/mom/test_return_call.rb index db696e3c..2f1f5f02 100644 --- a/test/mom/test_return_call.rb +++ b/test/mom/test_return_call.rb @@ -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 diff --git a/test/rubyx/test_rubyx_compiler2.rb b/test/rubyx/test_rubyx_compiler2.rb index 25c472f4..9b0c74ee 100644 --- a/test/rubyx/test_rubyx_compiler2.rb +++ b/test/rubyx/test_rubyx_compiler2.rb @@ -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 diff --git a/test/rubyx/test_rubyx_compiler3.rb b/test/rubyx/test_rubyx_compiler3.rb index 9d15f339..1407bd79 100644 --- a/test/rubyx/test_rubyx_compiler3.rb +++ b/test/rubyx/test_rubyx_compiler3.rb @@ -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 diff --git a/test/vool/blocks/test_if_condition.rb b/test/vool/blocks/test_if_condition.rb index 0b267f63..64d690c0 100644 --- a/test/vool/blocks/test_if_condition.rb +++ b/test/vool/blocks/test_if_condition.rb @@ -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 diff --git a/test/vool/test_if_condition.rb b/test/vool/test_if_condition.rb index 2a9aece0..d4b659ff 100644 --- a/test/vool/test_if_condition.rb +++ b/test/vool/test_if_condition.rb @@ -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 diff --git a/test/vool/test_return.rb b/test/vool/test_return.rb index 084160ad..8b15a158 100644 --- a/test/vool/test_return.rb +++ b/test/vool/test_return.rb @@ -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 diff --git a/test/vool/test_while_statement1.rb b/test/vool/test_while_statement1.rb index a202feb1..30699de8 100644 --- a/test/vool/test_while_statement1.rb +++ b/test/vool/test_while_statement1.rb @@ -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