2018-03-19 16:28:53 +05:30
|
|
|
require_relative '../helper'
|
2018-03-17 11:13:44 +05:30
|
|
|
|
|
|
|
module Risc
|
2018-03-19 13:19:42 +05:30
|
|
|
class TestAssignLocalConst < MiniTest::Test
|
2018-03-17 11:13:44 +05:30
|
|
|
include Statements
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@input = "r = 5"
|
2018-03-19 15:47:40 +05:30
|
|
|
@expect = [LoadConstant,SlotToReg, RegToSlot]
|
2018-03-17 11:13:44 +05:30
|
|
|
end
|
|
|
|
def test_local_assign_instructions
|
|
|
|
assert_nil msg = check_nil , msg
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_constant_load
|
|
|
|
produced = produce_body
|
2018-03-22 02:38:06 +05:30
|
|
|
assert_equal 5 , produced.constant.value
|
2018-03-17 11:13:44 +05:30
|
|
|
end
|
|
|
|
|
2018-03-24 15:59:54 +02:00
|
|
|
def test_frame_load
|
|
|
|
produced = produce_body
|
|
|
|
assert_equal :Message , produced.next(1).array.type
|
|
|
|
assert_equal 4 , produced.next(1).index # 4 is frame
|
|
|
|
end
|
|
|
|
def test_value_load
|
2018-03-17 11:13:44 +05:30
|
|
|
produced = produce_body
|
2018-03-19 15:47:40 +05:30
|
|
|
assert_equal produced.next(2).register , produced.register
|
2018-03-24 15:59:54 +02:00
|
|
|
assert_equal 2 , produced.next(2).index #type == 1 , r == 2
|
2018-03-17 11:13:44 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|