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