start to test call
as per tdd noticing logic errors, have to swap message out
This commit is contained in:
parent
b5ef929c9c
commit
49880267bb
@ -22,8 +22,9 @@ module Mom
|
|||||||
def to_risc(compiler)
|
def to_risc(compiler)
|
||||||
reg = compiler.use_reg(:int)
|
reg = compiler.use_reg(:int)
|
||||||
return_label = Risc::Label.new(self,"continue")
|
return_label = Risc::Label.new(self,"continue")
|
||||||
load = SlotLoad.new([:message,:next_message,:return_address],[return_label])
|
save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label])
|
||||||
moves = load.to_risc(compiler)
|
moves = save_return.to_risc(compiler)
|
||||||
|
moves << Risc.slot_to_reg(self, :message , :next_message , Risc.message_reg)
|
||||||
moves << Risc::FunctionCall.new(self, method ,reg)
|
moves << Risc::FunctionCall.new(self, method ,reg)
|
||||||
moves << return_label
|
moves << return_label
|
||||||
end
|
end
|
||||||
|
52
test/mom/test_send_simple.rb
Normal file
52
test/mom/test_send_simple.rb
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
require_relative "helper"
|
||||||
|
|
||||||
|
module Risc
|
||||||
|
class TestCallSimple < MiniTest::Test
|
||||||
|
include Statements
|
||||||
|
|
||||||
|
def setup
|
||||||
|
super
|
||||||
|
@input = "5.mod4"
|
||||||
|
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||||
|
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
||||||
|
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg ,
|
||||||
|
FunctionCall, Label]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_send_instructions
|
||||||
|
assert_nil msg = check_nil , msg
|
||||||
|
end
|
||||||
|
def test_function_call
|
||||||
|
produced = produce_body
|
||||||
|
assert_equal FunctionCall , produced.next(18).class
|
||||||
|
assert_equal :mod4 , produced.next(18).method.name
|
||||||
|
end
|
||||||
|
def test_load_label
|
||||||
|
produced = produce_body
|
||||||
|
assert_equal Label , produced.next(14).constant.known_object.class
|
||||||
|
end
|
||||||
|
def test_load_5
|
||||||
|
produced = produce_body
|
||||||
|
assert_equal 5 , produced.next(11).constant.known_object.value
|
||||||
|
end
|
||||||
|
|
||||||
|
def est_call_reg_setup
|
||||||
|
produced = produce_body
|
||||||
|
assert_equal produced.next(16).register , produced.next(17).register
|
||||||
|
end
|
||||||
|
def pest_nil_load
|
||||||
|
produced = produce_body
|
||||||
|
assert_equal Mom::NilConstant , produced.next(4).constant.known_object.class
|
||||||
|
end
|
||||||
|
def pest_nil_check
|
||||||
|
produced = produce_body
|
||||||
|
assert_equal produced.next(10) , produced.next(5).label
|
||||||
|
end
|
||||||
|
|
||||||
|
def pest_true_label
|
||||||
|
produced = produce_body
|
||||||
|
assert produced.next(6).name.start_with?("true_label")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user