2018-05-16 11:49:46 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-03 19:55:41 +02:00
|
|
|
module SlotMachine
|
2018-05-16 11:49:46 +02:00
|
|
|
class TestSlotLoad2 < MiniTest::Test
|
|
|
|
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2020-02-28 11:54:17 +01:00
|
|
|
compiler = Risc.test_compiler
|
2019-08-12 23:13:29 +02:00
|
|
|
load = SlotLoad.new( "test",[:message, :caller, :type] , [:message, :caller , :type] )
|
2020-02-28 11:54:17 +01:00
|
|
|
load.to_risc(compiler)
|
|
|
|
@instructions = compiler.risc_instructions.next
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
|
2018-08-19 14:36:51 +02:00
|
|
|
def test_ins_next_classes
|
2020-02-28 11:54:17 +01:00
|
|
|
assert_equal Risc::SlotToReg , @instructions.class
|
|
|
|
assert_equal Risc::SlotToReg , @instructions.next.class
|
|
|
|
assert_equal Risc::SlotToReg , @instructions.next(2).class
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_next_class
|
2020-02-28 11:54:17 +01:00
|
|
|
assert_equal Risc::RegToSlot , @instructions.next(3).class
|
|
|
|
assert_equal NilClass , @instructions.next(4).class
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_reg
|
2020-03-01 15:41:58 +01:00
|
|
|
assert_equal :"message.caller.type" , @instructions.next.register.symbol
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_arr
|
2020-03-01 15:41:58 +01:00
|
|
|
assert_equal :"message.caller" , @instructions.next.array.symbol
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_index
|
2020-02-28 11:54:17 +01:00
|
|
|
assert_equal 0 , @instructions.next.index
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
2018-07-13 20:56:55 +02:00
|
|
|
def test_ins_next_2_reg
|
2020-03-01 15:41:58 +01:00
|
|
|
assert_equal :"message.caller" , @instructions.next(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
|
2020-03-01 15:41:58 +01:00
|
|
|
assert_equal :"message" , @instructions.next(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
|
2020-02-28 11:54:17 +01:00
|
|
|
assert_equal 6 , @instructions.next(2).index
|
2018-07-13 20:56:55 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_3_reg
|
2020-03-01 15:41:58 +01:00
|
|
|
assert_equal :"message.caller.type" , @instructions.next(3).register.symbol
|
2018-07-13 20:56:55 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_3_arr
|
2020-03-01 15:41:58 +01:00
|
|
|
assert_equal :"message.caller" , @instructions.next(3).array.symbol
|
2018-07-13 20:56:55 +02:00
|
|
|
end
|
|
|
|
def test_ins_next_3_index
|
2020-02-28 11:54:17 +01:00
|
|
|
assert_equal 0 , @instructions.next(3).index
|
2018-05-16 11:49:46 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|