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
|
2019-09-13 19:34:41 +02:00
|
|
|
assert_equal 19 , @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
|
|
|
|
assert_load risc(1) , Parfait::Factory
|
|
|
|
assert_slot_to_reg risc(2) , :r1 , 2 , :r0
|
|
|
|
assert_slot_to_reg risc(3),:r0 , 1 , :r2
|
|
|
|
assert_reg_to_slot risc(4) , :r2 , :r1 , 2
|
|
|
|
assert_load risc(5) , Parfait::CallableMethod
|
|
|
|
assert_slot_to_reg risc(6),:r0 , 1 , :r2
|
|
|
|
assert_reg_to_slot risc(7) , :r1 , :r2 , 7
|
|
|
|
assert_slot_to_reg risc(8),:r0 , 1 , :r0
|
|
|
|
assert_load risc(9) , Parfait::Space
|
|
|
|
assert_reg_to_slot risc(10) , :r3 , :r0 , 2
|
|
|
|
assert_load risc(11) , Risc::Label
|
|
|
|
assert_reg_to_slot risc(12) , :r4 , :r0 , 4
|
|
|
|
assert_equal Risc::FunctionCall, risc(13).class
|
|
|
|
assert_equal :main, risc(13).method.name
|
|
|
|
assert_label risc(14) , "Object.__init__"
|
|
|
|
assert_transfer risc(15) , :r0 , :r8
|
|
|
|
assert_slot_to_reg risc(16),:r0 , 5 , :r0
|
|
|
|
assert_slot_to_reg risc(17),:r0 , 2 , :r0
|
|
|
|
assert_equal Risc::Syscall, risc(18).class
|
|
|
|
assert_equal :exit, risc(18).name
|
|
|
|
end
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|