rubyx/test/slot_machine/instruction/test_slot_load3.rb
Torsten 4888b3b6db Starting to rework slot instructions that create risc
have to go through all and all macros and all thems tests. What did the wise man say: one step at a time
2020-03-22 14:31:43 +02:00

52 lines
1.5 KiB
Ruby

require_relative "helper"
module SlotMachine
class TestSlotLoad3 < MiniTest::Test
include Parfait::MethodHelper
def setup
Parfait.boot!(Parfait.default_test_options)
method = make_method
compiler = Risc.test_compiler
@cache_entry = Parfait::CacheEntry.new(method.frame_type, method)
load = SlotLoad.new("test", [@cache_entry , :cached_type] , [:message, :type] )
load.to_risc(compiler)
@instructions = compiler.risc_instructions.next
end
def test_ins_next_class
assert_equal Risc::SlotToReg , @instructions.class
assert_equal Risc::LoadConstant, @instructions.next.class
end
def test_ins_next_class
assert_equal Risc::RegToSlot , @instructions.next(2).class
assert_equal NilClass , @instructions.next(3).class
end
def test_ins_load
assert @instructions.next.register.is_object?
assert_equal Parfait::CacheEntry , @instructions.next.constant.class
end
def test_ins_next_reg
assert_equal :"message.type" , @instructions.register.symbol
end
def test_ins_next_arr
assert_equal :message , @instructions.array.symbol
end
def test_ins_next_index
assert_equal 0 , @instructions.index
end
def test_ins_next_2_reg
assert_equal :"message.type" , @instructions.next(2).register.symbol
end
def test_ins_next_2_arr
assert @instructions.next(2).array.is_object?
end
def test_ins_next_2_index
assert_equal 1 , @instructions.next(2).index
end
end
end