2018-03-19 11:58:53 +01:00
|
|
|
require_relative '../helper'
|
2018-03-17 06:43:44 +01:00
|
|
|
|
|
|
|
module Risc
|
2018-03-19 08:49:42 +01:00
|
|
|
class TestAssignLocalConst < MiniTest::Test
|
2018-03-17 06:43:44 +01:00
|
|
|
include Statements
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@input = "r = 5"
|
2018-03-19 11:17:40 +01:00
|
|
|
@expect = [LoadConstant,SlotToReg, RegToSlot]
|
2018-03-17 06:43:44 +01:00
|
|
|
end
|
|
|
|
def test_local_assign_instructions
|
|
|
|
assert_nil msg = check_nil , msg
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_constant_load
|
|
|
|
produced = produce_body
|
2018-03-17 16:45:38 +01:00
|
|
|
assert_equal 5 , produced.constant.known_object.value
|
2018-03-17 06:43:44 +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-17 06:43:44 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|