2018-04-05 11:19:29 +02:00
|
|
|
require_relative "../helper"
|
2018-03-21 14:50:51 +01:00
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestCallSimple < MiniTest::Test
|
|
|
|
include Statements
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
2018-04-19 09:00:55 +02:00
|
|
|
@input = "5.div4"
|
2018-08-12 14:02:23 +02:00
|
|
|
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
|
|
|
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
|
2019-08-17 22:29:42 +02:00
|
|
|
FunctionCall, Label, SlotToReg, RegToSlot, Branch]
|
2018-03-21 14:50:51 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_send_instructions
|
|
|
|
assert_nil msg = check_nil , msg
|
|
|
|
end
|
2018-03-30 17:13:17 +02:00
|
|
|
def test_load_5
|
2018-08-12 14:02:23 +02:00
|
|
|
produced = produce_body.next(8)
|
|
|
|
assert_load( produced , Parfait::Integer)
|
|
|
|
assert_equal 5 , produced.constant.value
|
2018-03-21 17:35:51 +01:00
|
|
|
end
|
2018-03-21 14:50:51 +01:00
|
|
|
def test_load_label
|
2018-08-12 14:02:23 +02:00
|
|
|
produced = produce_body.next(11)
|
|
|
|
assert_load( produced , Label)
|
2018-03-21 14:50:51 +01:00
|
|
|
end
|
2018-03-30 17:13:17 +02:00
|
|
|
def test_function_call
|
2018-08-12 14:02:23 +02:00
|
|
|
produced = produce_body.next(15)
|
|
|
|
assert_equal FunctionCall , produced.class
|
|
|
|
assert_equal :div4 , produced.method.name
|
2018-03-30 17:13:17 +02:00
|
|
|
end
|
|
|
|
def test_check_continue
|
2018-08-12 14:02:23 +02:00
|
|
|
produced = produce_body.next(16)
|
|
|
|
assert_equal Label , produced.class
|
|
|
|
assert produced.name.start_with?("continue_")
|
2018-03-30 17:13:17 +02:00
|
|
|
end
|
2018-03-21 14:59:00 +01:00
|
|
|
#TODO check the message setup, type and frame moves
|
2018-03-21 14:50:51 +01:00
|
|
|
end
|
|
|
|
end
|