2018-03-19 11:58:53 +01:00
|
|
|
require_relative '../helper'
|
2018-03-19 09:00:14 +01:00
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestAssignLocalIvar < MiniTest::Test
|
|
|
|
include Statements
|
|
|
|
|
|
|
|
def setup
|
2019-09-12 21:27:10 +02:00
|
|
|
@input = "@nil_object = 5 ; r = @nil_object;return"
|
2019-08-23 09:21:22 +02:00
|
|
|
@expect = [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #4
|
|
|
|
RegToSlot, LoadConstant, RegToSlot, Branch] #9
|
2018-03-19 09:00:14 +01:00
|
|
|
end
|
|
|
|
def test_local_assign_instructions
|
|
|
|
assert_nil msg = check_nil , msg
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_constant_load
|
|
|
|
produced = produce_body
|
2018-03-21 22:08:06 +01:00
|
|
|
assert_equal 5 , produced.constant.value
|
2018-03-19 09:00:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_slot_move
|
|
|
|
produced = produce_body
|
2018-03-19 11:17:40 +01:00
|
|
|
assert_equal produced.next(2).register , produced.register
|
2018-03-19 09:00:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|