2019-08-12 12:16:15 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-03 19:55:41 +02:00
|
|
|
module SlotMachine
|
2019-08-12 12:16:15 +02:00
|
|
|
module Builtin
|
2020-03-12 16:54:39 +01:00
|
|
|
class TestSetInternalByte < BootTest
|
2019-08-12 12:16:15 +02:00
|
|
|
def setup
|
|
|
|
super
|
2020-03-12 16:54:39 +01:00
|
|
|
@method = get_compiler("Word",:set_byte)
|
2019-09-13 09:41:13 +02:00
|
|
|
end
|
2019-10-03 19:55:41 +02:00
|
|
|
def test_slot_length
|
2019-09-13 09:41:13 +02:00
|
|
|
assert_equal :set_internal_byte , @method.callable.name
|
2019-10-03 19:55:41 +02:00
|
|
|
assert_equal 7 , @method.slot_instructions.length
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|
|
|
|
def test_compile
|
|
|
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
|
|
|
end
|
|
|
|
def test_risc_length
|
2019-09-13 13:07:12 +02:00
|
|
|
assert_equal 20 , @method.to_risc.risc_instructions.length
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|
2020-03-06 17:09:56 +01:00
|
|
|
def test_all
|
2020-03-11 21:54:44 +01:00
|
|
|
assert_slot_to_reg 1 ,:message , 10 , "message.arg2"
|
|
|
|
assert_reg_to_slot 2 , "message.arg2" , :message , 5
|
|
|
|
assert_slot_to_reg 3 ,:message , 9 , "message.arg1"
|
|
|
|
assert_slot_to_reg 4 ,"message.arg1" , 2 , "message.arg1.data_1"
|
|
|
|
assert_slot_to_reg 5 ,:message , 2 , "message.receiver"
|
|
|
|
assert_slot_to_reg 6 ,:message , 10 , "message.arg2"
|
|
|
|
assert_slot_to_reg 7 ,"message.arg2" , 2 , "message.arg2.data_1"
|
|
|
|
assert_equal Risc::RegToByte , risc(8).class
|
|
|
|
assert_slot_to_reg 9 ,:message , 5 , "message.return_value"
|
|
|
|
assert_reg_to_slot 10 , "message.return_value" , :message , 5
|
|
|
|
assert_branch 11 , "return_label"
|
|
|
|
assert_label 12 , "return_label"
|
2020-03-06 17:09:56 +01:00
|
|
|
end
|
|
|
|
def test_return
|
2020-03-11 21:54:44 +01:00
|
|
|
assert_return(12)
|
2020-03-06 17:09:56 +01:00
|
|
|
end
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|