rubyx/test/mom/send/test_send_simple_args.rb

69 lines
2.0 KiB
Ruby
Raw Normal View History

2018-04-05 11:19:29 +02:00
require_relative "../helper"
2018-03-30 17:05:38 +02:00
module Risc
class TestCallSimpleArgs < MiniTest::Test
include Statements
def setup
@preload = "Object.get"
2018-03-30 17:05:38 +02:00
@input = "5.get_internal_word(1)"
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #10
SlotToReg, RegToSlot, SlotToReg, FunctionCall, Label, #15
SlotToReg, RegToSlot, Branch,] #20
2018-03-30 17:05:38 +02: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-03-30 17:05:38 +02:00
produced = produce_body
assert_equal LoadConstant , produced.next(3).class
assert_equal 5 , produced.next(3).constant.value
2018-04-06 22:37:41 +02:00
end
def base
6
2018-03-30 17:05:38 +02:00
end
def test_load_arg_const
produced = produce_body
assert_load( produced.next(base) , Parfait::Integer )
assert_equal 1 , produced.next(base).constant.value
end
def test_load_next_m
produced = produce_body.next(base+1)
assert_slot_to_reg( produced ,:r0 ,1 , :r2 )
end
def test_store_arg_at
2019-08-22 21:56:44 +02:00
produced = produce_body.next(base+2)
assert_reg_to_slot( produced ,:r1 ,:r2 , 9 )
end
2018-03-30 17:13:17 +02:00
def test_load_label
2019-08-22 21:56:44 +02:00
produced = produce_body.next(base+3)
assert_load( produced , Label )
2018-03-30 17:05:38 +02:00
end
def test_load_some
2019-08-22 21:56:44 +02:00
produced = produce_body.next(base+4)
assert_slot_to_reg( produced ,:r0 ,1 , :r2 )
end
def test_store_
2019-08-22 21:56:44 +02:00
produced = produce_body.next(base+5)
assert_reg_to_slot( produced ,:r1 ,:r2 , 4 )
end
def test_swap_messages
2019-08-22 21:56:44 +02:00
produced = produce_body.next(base+6)
assert_slot_to_reg( produced ,:r0 ,1 , :r0 )
end
2018-03-30 17:13:17 +02:00
def test_function_call
2018-03-30 17:05:38 +02:00
produced = produce_body
2019-08-22 21:56:44 +02:00
assert_equal FunctionCall , produced.next(base+7).class
assert_equal :get_internal_word , produced.next(base+7).method.name
2018-03-30 17:05:38 +02:00
end
2018-03-30 17:13:17 +02:00
def test_check_continue
2018-03-30 17:05:38 +02:00
produced = produce_body
2019-08-22 21:56:44 +02:00
assert produced.next(base+8).name.start_with?("continue_")
2018-03-30 17:05:38 +02:00
end
end
end