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 TestObjectInitRisc < BootTest
|
|
|
|
def setup
|
2019-09-24 20:20:12 +02:00
|
|
|
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
2019-10-03 19:55:41 +02:00
|
|
|
coll = compiler.ruby_to_slot( get_preload("Space.main") )
|
|
|
|
@method = SlotCollection.create_init_compiler
|
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 :__init__ , @method.callable.name
|
2019-10-03 19:55:41 +02:00
|
|
|
assert_equal 2 , @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-15 09:39:09 +01: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-10 16:21:49 +01:00
|
|
|
assert_load 1 , Parfait::Factory , "id_factory_"
|
|
|
|
assert_slot_to_reg 2 , "id_factory_" , 2 , :message
|
|
|
|
assert_slot_to_reg 3 ,:message , 1 , "message.next_message"
|
|
|
|
assert_reg_to_slot 4 , "message.next_message" , "id_factory_" , 2
|
|
|
|
assert_load 5 , Parfait::CallableMethod , "id_callablemethod_"
|
|
|
|
assert_slot_to_reg 6 ,:message , 1 , "message.next_message"
|
|
|
|
assert_reg_to_slot 7 , "id_callablemethod_" , "message.next_message" , 7
|
|
|
|
assert_slot_to_reg 8 ,:message , 1 , :message
|
|
|
|
assert_load 9 , Parfait::Space , "id_space_"
|
|
|
|
assert_reg_to_slot 10 , "id_space_" , :message , 2
|
|
|
|
assert_load 11 , Risc::Label , "id_label_"
|
|
|
|
assert_reg_to_slot 12 , "id_label_" , :message , 4
|
2020-03-10 16:27:13 +01:00
|
|
|
assert_function_call 13 , :main
|
2020-03-10 16:21:49 +01:00
|
|
|
assert_label 14 , "Object.__init__"
|
|
|
|
assert_transfer 15 , :message , :saved_message
|
2020-03-16 16:51:21 +01:00
|
|
|
assert_slot_to_reg 16 ,:message , 5 , :"message.return_value"
|
|
|
|
assert_slot_to_reg 17 ,:"message.return_value" , 2 , "message.return_value.data_1"
|
|
|
|
assert_transfer 18 , "message.return_value.data_1" , :syscall_1
|
2020-03-15 09:39:09 +01:00
|
|
|
assert_syscall 19, :exit
|
2020-03-06 17:09:56 +01:00
|
|
|
end
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|