2018-05-16 11:49:46 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Mom
|
|
|
|
class TestSlotLoad2 < MiniTest::Test
|
|
|
|
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-07-16 10:46:18 +02:00
|
|
|
@compiler = Risc::FakeCompiler.new
|
2018-08-19 12:06:00 +02:00
|
|
|
load = SlotLoad.new( [:message, :caller, :type] , [:message, :caller , :type] )
|
|
|
|
load.to_risc(@compiler)
|
|
|
|
@instructions = @compiler.instructions
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
|
2018-08-19 14:36:51 +02:00
|
|
|
def test_ins_next_classes
|
|
|
|
assert_equal Risc::SlotToReg , @instructions[0].class
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal Risc::SlotToReg , @instructions[1].class
|
|
|
|
assert_equal Risc::SlotToReg , @instructions[2].class
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_next_class
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal Risc::RegToSlot , @instructions[3].class
|
2018-08-19 14:36:51 +02:00
|
|
|
assert_equal NilClass , @instructions[4].class
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_ins_next_reg
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal :r1 , @instructions[1].register.symbol
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_arr
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal :r1 , @instructions[1].array.symbol
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_index
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal 0 , @instructions[1].index
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
|
2018-07-13 20:56:55 +02:00
|
|
|
def test_ins_next_2_reg
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal :r1 , @instructions[2].register.symbol
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
2018-07-13 20:56:55 +02:00
|
|
|
def test_ins_next_2_arr
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal :r0 , @instructions[2].array.symbol
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
2018-07-13 20:56:55 +02:00
|
|
|
def test_ins_next_2_index
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal 6 , @instructions[2].index
|
2018-07-13 20:56:55 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_ins_next_3_reg
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal :r1 , @instructions[3].register.symbol
|
2018-07-13 20:56:55 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_3_arr
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal :r1 , @instructions[3].array.symbol
|
2018-07-13 20:56:55 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_3_index
|
2018-08-19 12:06:00 +02:00
|
|
|
assert_equal 0 , @instructions[3].index
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|