rubyx/test/risc/interpreter/assign/test_assign_local.rb

47 lines
1.4 KiB
Ruby
Raw Normal View History

2018-04-23 12:16:46 +02:00
require_relative "../helper"
module Risc
class InterpreterAssignLocal < MiniTest::Test
include Ticker
def setup
@string_input = as_main("a = 15 ; return a")
super
end
2018-05-24 20:20:56 +02:00
def test_chain
#show_main_ticks # get output of what is
2020-03-13 19:18:34 +01:00
check_main_chain [LoadConstant, RegToSlot, SlotToReg, RegToSlot, Branch, #5
2019-08-23 14:31:22 +02:00
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #10
2020-03-13 19:18:34 +01:00
FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #15
NilClass,] #20
assert_equal Parfait::Integer , get_return.class
assert_equal 15 , get_return.value
end
2018-05-24 20:20:56 +02:00
def test_call_main
2018-04-06 22:37:41 +02:00
call_ins = ticks(main_at)
assert_equal FunctionCall , call_ins.class
assert :main , call_ins.method.name
end
def test_load_15
2020-03-13 19:18:34 +01:00
assert_load 1 , Parfait::Integer , "id_integer_"
assert_equal 15 , @interpreter.get_register(@interpreter.instruction.register).value
end
def test_branch
assert_branch 5 , "return_label"
end
2018-05-24 20:20:56 +02:00
def test_return
2020-03-13 19:18:34 +01:00
ret = main_ticks(11)
assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register )
2020-03-13 19:18:34 +01:00
assert_equal Parfait::ReturnAddress , link.class
end
2018-05-24 20:20:56 +02:00
def test_transfer
2020-03-13 19:18:34 +01:00
assert_transfer 12 , :message , :saved_message
end
2018-05-24 20:20:56 +02:00
def test_sys
2020-03-13 19:18:34 +01:00
assert_syscall 15 , :exit
end
end
end