diff --git a/test/slot_machine/instructions/test_slot_load.rb b/test/slot_machine/instructions/test_slot_load.rb index 91e2cb5e..8041dbe2 100644 --- a/test/slot_machine/instructions/test_slot_load.rb +++ b/test/slot_machine/instructions/test_slot_load.rb @@ -12,13 +12,5 @@ module SlotMachine def test_ins_fail1 assert_raises {SlotLoad.new( "test",[:message, :caller] , nil )} end - def pest_fail_on_right - load = SlotLoad.new( "test",[:message, :caller] , [:message ,:receiver,:type] ) - assert_raises {load.to_risc(Risc.test_compiler)} - end - def pest_fail_on_left_long - load = SlotLoad.new("test", [:message, :caller , :type , :type] , [:message,:type] ) - assert_raises {load.to_risc(Risc.test_compiler)} - end end end diff --git a/test/slot_machine/instructions/test_slot_load1.rb b/test/slot_machine/instructions/test_slot_load1.rb index 29f253a7..a8b3a23f 100644 --- a/test/slot_machine/instructions/test_slot_load1.rb +++ b/test/slot_machine/instructions/test_slot_load1.rb @@ -10,30 +10,16 @@ module SlotMachine load.to_risc(compiler) @instructions = compiler.risc_instructions.next end - - def test_ins_class - assert_equal Risc::SlotToReg , @instructions.class + def risc(i) + return @instructions if i == 0 + @instructions.next(i) end - def test_ins_next_class - assert_equal Risc::RegToSlot , @instructions.next.class + def test_ins_0 + assert_slot_to_reg 0 , :message , 0 , "message.type" end - def test_ins_arr - assert_equal :message , @instructions.array.symbol - end - def test_ins_reg - assert_equal :"message.type" , @instructions.register.symbol - end - def test_ins_index - assert_equal 0 , @instructions.index - end - def test_ins_next_reg - assert_equal :"message.type" , @instructions.next.register.symbol - end - def test_ins_next_arr - assert_equal :message , @instructions.next.array.symbol - end - def test_ins_next_index - assert_equal 6 , @instructions.next.index + def test_ins_1 + assert_reg_to_slot 1 , "message.type" , :message , 6 + assert_nil risc(2) end end end diff --git a/test/slot_machine/instructions/test_slot_load2.rb b/test/slot_machine/instructions/test_slot_load2.rb index 77a2c2a5..997113b1 100644 --- a/test/slot_machine/instructions/test_slot_load2.rb +++ b/test/slot_machine/instructions/test_slot_load2.rb @@ -10,27 +10,22 @@ module SlotMachine load.to_risc(compiler) @instructions = compiler.risc_instructions.next end - - def test_ins_next_classes - assert_equal Risc::SlotToReg , @instructions.class - assert_equal Risc::SlotToReg , @instructions.next.class - assert_equal Risc::SlotToReg , @instructions.next(2).class - end - def test_ins_next_next_class - assert_equal Risc::RegToSlot , @instructions.next(3).class - assert_equal NilClass , @instructions.next(4).class + def risc(i) + return @instructions if i == 0 + @instructions.next(i) end def test_ins - assert_slot_to_reg @instructions ,:message , 6 , "message.caller" + assert_slot_to_reg 0 ,:message , 6 , "message.caller" end def test_ins_next - assert_slot_to_reg @instructions.next ,"message.caller" , 0 , "message.caller.type" + assert_slot_to_reg 1 ,"message.caller" , 0 , "message.caller.type" end def test_ins_next_2 - assert_slot_to_reg @instructions.next(2) , :message , 6 , "message.caller" + assert_slot_to_reg 2 , :message , 6 , "message.caller" end def test_ins_next_3 - assert_reg_to_slot @instructions.next(3) ,"message.caller.type" , "message.caller" , 0 + assert_reg_to_slot 3 ,"message.caller.type" , "message.caller" , 0 + assert_equal NilClass , @instructions.next(4).class end end end diff --git a/test/slot_machine/instructions/test_slot_load3.rb b/test/slot_machine/instructions/test_slot_load3.rb index 4c7a8613..6c204738 100644 --- a/test/slot_machine/instructions/test_slot_load3.rb +++ b/test/slot_machine/instructions/test_slot_load3.rb @@ -13,22 +13,19 @@ module SlotMachine load.to_risc(compiler) @instructions = compiler.risc_instructions.next end - def test_ins_next_class - assert_equal Risc::SlotToReg , @instructions.class - assert_equal Risc::LoadConstant, @instructions.next.class - end - def test_ins_next_class - assert_equal Risc::RegToSlot , @instructions.next(2).class - assert_equal NilClass , @instructions.next(3).class + def risc(i) + return @instructions if i == 0 + @instructions.next(i) end def test_ins - assert_slot_to_reg @instructions , :message , 0 , "message.type" + assert_slot_to_reg 0 , :message , 0 , "message.type" end def test_ins_next - assert_load @instructions.next , Parfait::CacheEntry , "id_" + assert_load 1 , Parfait::CacheEntry , "id_" end def test_ins_next_2 - assert_reg_to_slot @instructions.next(2) , :"message.type" , "id_", 1 + assert_reg_to_slot 2 , :"message.type" , "id_", 1 + assert_equal NilClass , @instructions.next(3).class end end diff --git a/test/slot_machine/instructions/test_truth_check.rb b/test/slot_machine/instructions/test_truth_check.rb index 6d4be7bd..d5f1c8c5 100644 --- a/test/slot_machine/instructions/test_truth_check.rb +++ b/test/slot_machine/instructions/test_truth_check.rb @@ -20,7 +20,7 @@ module SlotMachine assert_operator 3, :- , "id_" , "message.caller" end def test_4_zero - assert_not_zero 4 , "target" + assert_zero 4 , "target" end def test_5_load assert_load 5, Parfait::NilClass , "id_" @@ -29,7 +29,7 @@ module SlotMachine assert_operator 6, :- , "id_", "message.caller" end def test_7_zero - assert_not_zero 7 , "target" + assert_zero 7 , "target" end end end diff --git a/test/support/risc_assert.rb b/test/support/risc_assert.rb index 02e91fd2..9f64dacd 100644 --- a/test/support/risc_assert.rb +++ b/test/support/risc_assert.rb @@ -109,16 +109,16 @@ module Minitest def assert_zero ins_i , label assert_equal Integer , ins_i.class, "assert_zero #{ins_i}" ins = risc(ins_i) - assert_equal Risc::IsNotZero , ins.class , "Class at:#{ins_i}" + assert_equal Risc::IsZero , ins.class , "Class at:#{ins_i}" assert_label ins.label , label , "Label at:#{ins_i}" end def assert_not_zero ins_i , label assert_equal Integer , ins_i.class, "assert_not_zero #{ins_i}" ins = risc(ins_i) - assert_equal Risc::IsZero , ins.class, "Class at:#{ins_i}" + assert_equal Risc::IsNotZero , ins.class, "Class at:#{ins_i}" assert_label ins.label , label, "Label at:#{ins_i}" end - def assert_syscall ins , name + def assert_syscall ins_i , name assert_equal Integer , ins_i.class, "assert_syscall #{ins_i}" ins = risc(ins_i) assert_equal Risc::Syscall , ins.class, "Class at:#{ins_i}"