rubyx/test/vool/test_return.rb
Torsten Ruger c947c27a14 clean up booting
many machine boot became obsolete
or just neede parfait to boot
actual linker functionality pending
2018-07-01 14:12:42 +03:00

59 lines
1.4 KiB
Ruby

require_relative "helper"
module Vool
class TestReturnMom < MiniTest::Test
include MomCompile
include Mom
def setup
Parfait.boot!
@inst = compile_first_method( "return 5")
end
def test_class_compiles
assert_equal SlotLoad , @inst.class , @inst
end
def test_slot_is_set
assert @inst.left
end
def test_two_instructions_are_returned
assert_equal 2 , @inst.length
end
def test_second_is_return
assert_equal ReturnSequence, @inst.last.class
end
def test_slot_starts_at_message
assert_equal :message , @inst.left.known_object
end
def test_slot_gets_return
assert_equal :return_value , @inst.left.slots[0]
end
def test_slot_assigns_something
assert @inst.right
end
def test_slot_assigns_int
assert_equal Mom::IntegerConstant , @inst.right.known_object.class
end
def test_array
check_array [SlotLoad,ReturnSequence] , @ins
end
end
class TestReturnSendMom < MiniTest::Test
include MomCompile
include Mom
def setup
Parfait.boot!
Risc.boot!
@ins = compile_first_method( "return 5.div4")
end
def test_return_is_last
assert_equal ReturnSequence , @ins.last.class
end
def test_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,SlotLoad,ReturnSequence] , @ins
end
end
end