fixing most of the mom tests

This commit is contained in:
2019-08-23 15:31:04 +03:00
parent 89f32ed74a
commit 50c172915e
30 changed files with 110 additions and 192 deletions

View File

@ -14,11 +14,10 @@ module Risc
SlotToReg, OperatorInstruction, IsZero, SlotToReg, Branch, #24
Label, LoadConstant, SlotToReg, Transfer, Syscall, #29
Transfer, Transfer, SlotToReg, RegToSlot, Label, #34
RegToSlot, Label, LoadConstant, SlotToReg, LoadConstant, #39
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, #44
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, #49
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, #54
SlotToReg, DynamicJump, Label, SlotToReg, RegToSlot, Branch]
RegToSlot, Label, LoadConstant, SlotToReg, RegToSlot, #39
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, #44
SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg, #49
DynamicJump, Label, SlotToReg, RegToSlot, Branch,] #54
end
def test_send_instructions
@ -31,12 +30,12 @@ module Risc
end
def test_load_address
produced = produce_body
assert_equal LoadConstant , produced.next(39).class
assert_equal Parfait::Factory , produced.next(39).constant.class
assert_equal LoadConstant , produced.next(26).class
assert_equal Parfait::Factory , produced.next(26).constant.class
end
def test_function_call
produced = produce_body
assert_equal DynamicJump , produced.next(56).class
assert_equal DynamicJump , produced.next(50).class
end
def test_cache_check
produced = produce_body

View File

@ -7,31 +7,30 @@ module Risc
def setup
super
@input = "5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label, SlotToReg, RegToSlot, Branch]
@expect = [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #4
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, #9
Label, SlotToReg, RegToSlot, Branch,] #14
end
def test_send_instructions
assert_nil msg = check_nil , msg
end
def test_load_5
produced = produce_body.next(8)
produced = produce_body.next(2)
assert_load( produced , Parfait::Integer)
assert_equal 5 , produced.constant.value
end
def test_load_label
produced = produce_body.next(11)
produced = produce_body.next(5)
assert_load( produced , Label)
end
def test_function_call
produced = produce_body.next(15)
produced = produce_body.next(9)
assert_equal FunctionCall , produced.class
assert_equal :div4 , produced.method.name
end
def test_check_continue
produced = produce_body.next(16)
produced = produce_body.next(10)
assert_equal Label , produced.class
assert produced.name.start_with?("continue_")
end

View File

@ -7,11 +7,10 @@ module Risc
def setup
super
@input = "5.get_internal_word(1)"
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, #4
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, #9
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #14
SlotToReg, RegToSlot, SlotToReg, FunctionCall, Label, #19
SlotToReg, RegToSlot, Branch] #24
@expect = [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #4
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #9
RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg, #14
RegToSlot, Branch,] #19
end
def test_send_instructions
@ -19,11 +18,11 @@ module Risc
end
def test_load_5
produced = produce_body
assert_equal LoadConstant , produced.next(8).class
assert_equal 5 , produced.next(8).constant.value
assert_equal LoadConstant , produced.next(2).class
assert_equal 5 , produced.next(2).constant.value
end
def base
11
5
end
def test_load_arg_const
produced = produce_body

View File

@ -7,53 +7,23 @@ module Risc
def setup
super
@input = "return 5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label, SlotToReg, RegToSlot, Branch]
@expect = [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #4
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, #9
Label, SlotToReg, RegToSlot, Branch] #14
@produced = produce_body
end
def test_send_instructions
assert_nil msg = check_nil , msg
end
def pest_load_method
def test_load_method
method = @produced
assert_load( method, Parfait::CallableMethod ,:r1)
assert_equal :div4 , method.constant.name
end
def pest_load_space
space = @produced.next(1)
assert_load( space , Parfait::Factory , :r2 )
end
def pest_load_first_message #from space (ie r2)
sl = @produced.next( 2 )
assert_slot_to_reg( sl , :r2 , 2 , :r3 )
end
def pest_get_next_next #reduce onto itself
sl = @produced.next( 3 )
assert_slot_to_reg( sl , :r3 , 1 , :r4 )
end
def pest_store_next_next_in_space
sl = @produced.next( 4 )
assert_reg_to_slot( sl , :r4 , :r2 , 2 )
end
def pest_store_message_in_current
sl = @produced.next( 5 )
assert_reg_to_slot( sl , :r3 , :r0 , 1 )
end
def pest_store_caller_in_message
sl = @produced.next( 6 )
assert_reg_to_slot( sl , :r0 , :r3 , 6 )
end
def pest_store_method_in_message
sl = @produced.next( 7 )
assert_reg_to_slot( sl , :r1 , :r3 , 7 )
end
def pest_label
sl = @produced.next( 20 )
assert_equal Risc::Label , sl.class
assert_equal "return_label" , sl.name
def test_store_method_in_message
sl = @produced.next( 1 )
assert_reg_to_slot( sl , :r1 , :r2 , 7 )
end
end
end