2018-08-19 14:36:51 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-03 19:55:41 +02:00
|
|
|
module SlotMachine
|
2019-09-17 09:18:45 +02:00
|
|
|
class TestSlotLoad3 < MiniTest::Test
|
|
|
|
include Parfait::MethodHelper
|
2018-08-19 14:36:51 +02:00
|
|
|
|
|
|
|
def setup
|
2019-09-17 09:18:45 +02:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-08-19 14:36:51 +02:00
|
|
|
method = make_method
|
2020-02-28 11:54:17 +01:00
|
|
|
compiler = Risc.test_compiler
|
2018-08-19 14:36:51 +02:00
|
|
|
@cache_entry = Parfait::CacheEntry.new(method.frame_type, method)
|
2019-08-10 20:59:31 +02:00
|
|
|
load = SlotLoad.new("test", [@cache_entry , :cached_type] , [:message, :type] )
|
2020-02-28 11:54:17 +01:00
|
|
|
load.to_risc(compiler)
|
|
|
|
@instructions = compiler.risc_instructions.next
|
2018-08-19 14:36:51 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_class
|
2020-02-28 11:54:17 +01:00
|
|
|
assert_equal Risc::SlotToReg , @instructions.class
|
|
|
|
assert_equal Risc::LoadConstant, @instructions.next.class
|
2018-08-19 14:36:51 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_class
|
2020-02-28 11:54:17 +01:00
|
|
|
assert_equal Risc::RegToSlot , @instructions.next(2).class
|
|
|
|
assert_equal NilClass , @instructions.next(3).class
|
2018-08-19 14:36:51 +02:00
|
|
|
end
|
2020-03-02 16:50:03 +01:00
|
|
|
def test_ins
|
|
|
|
assert_slot_to_reg @instructions , :message , 0 , "message.type"
|
2018-08-19 14:36:51 +02:00
|
|
|
end
|
2020-03-02 16:50:03 +01:00
|
|
|
def test_ins_next
|
|
|
|
assert_load @instructions.next , Parfait::CacheEntry , "id_"
|
2018-08-19 14:36:51 +02:00
|
|
|
end
|
2020-03-02 16:50:03 +01:00
|
|
|
def test_ins_next_2
|
|
|
|
assert_reg_to_slot @instructions.next(2) , :"message.type" , "id_", 1
|
2018-08-19 14:36:51 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|