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
|
|
|
|
class TestObjectExitRisc < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
2019-09-13 09:41:13 +02:00
|
|
|
@method = get_compiler("Object",:exit)
|
|
|
|
end
|
2019-10-03 19:55:41 +02:00
|
|
|
def test_slot_length
|
2019-09-13 09:41:13 +02:00
|
|
|
assert_equal :exit , @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
|
2020-03-09 18:22:24 +01:00
|
|
|
assert_equal 38 , @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_allocate
|
|
|
|
assert_allocate
|
|
|
|
end
|
|
|
|
def test_all
|
2020-03-09 18:22:24 +01:00
|
|
|
a = Risc.allocate_length
|
|
|
|
assert_reg_to_slot a + 1 , "id_factory_.next_object" , :message , 5
|
|
|
|
assert_transfer a + 2 , :message , :saved_message
|
|
|
|
assert_slot_to_reg a + 3 ,:message , 5 , :message
|
|
|
|
assert_slot_to_reg a + 4 ,:message , 2 , "message.data_1"
|
|
|
|
assert_syscall a + 5 , :exit
|
|
|
|
assert_slot_to_reg a + 6 ,:message , 5 , "message.return_value"
|
|
|
|
assert_reg_to_slot a + 7 , "message.return_value" , :message , 5
|
|
|
|
assert_branch a + 8 , "return_label"
|
|
|
|
assert_label a + 9 , "return_label"
|
2020-03-06 17:09:56 +01:00
|
|
|
end
|
|
|
|
def test_return
|
2020-03-09 18:22:24 +01:00
|
|
|
assert_return(30)
|
2020-03-06 17:09:56 +01:00
|
|
|
end
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|