2017-04-14 09:52:23 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Vool
|
|
|
|
class TestReturnMom < MiniTest::Test
|
|
|
|
include MomCompile
|
2018-03-16 14:56:27 +01:00
|
|
|
include Mom
|
2017-04-14 09:52:23 +02:00
|
|
|
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-03-16 14:56:27 +01:00
|
|
|
@inst = compile_first_method( "return 5")
|
2017-04-14 09:52:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_class_compiles
|
2018-03-16 14:56:27 +01:00
|
|
|
assert_equal SlotLoad , @inst.class , @inst
|
2017-04-14 09:52:23 +02:00
|
|
|
end
|
|
|
|
def test_slot_is_set
|
2018-03-16 14:56:27 +01:00
|
|
|
assert @inst.left
|
2017-04-14 09:52:23 +02:00
|
|
|
end
|
2017-04-14 20:01:50 +02:00
|
|
|
def test_two_instructions_are_returned
|
2018-03-16 14:56:27 +01:00
|
|
|
assert_equal 2 , @inst.length
|
2017-04-14 20:01:50 +02:00
|
|
|
end
|
|
|
|
def test_second_is_return
|
2018-08-02 16:37:27 +02:00
|
|
|
assert_equal ReturnJump, @inst.last.class
|
2017-04-14 20:01:50 +02:00
|
|
|
end
|
2017-04-14 09:52:23 +02:00
|
|
|
def test_slot_starts_at_message
|
2018-03-16 14:56:27 +01:00
|
|
|
assert_equal :message , @inst.left.known_object
|
2017-04-14 09:52:23 +02:00
|
|
|
end
|
2017-04-14 20:01:50 +02:00
|
|
|
def test_slot_gets_return
|
2018-03-16 14:56:27 +01:00
|
|
|
assert_equal :return_value , @inst.left.slots[0]
|
2017-04-14 09:52:23 +02:00
|
|
|
end
|
|
|
|
def test_slot_assigns_something
|
2018-03-16 14:56:27 +01:00
|
|
|
assert @inst.right
|
2017-04-14 09:52:23 +02:00
|
|
|
end
|
|
|
|
def test_slot_assigns_int
|
2018-03-17 16:45:38 +01:00
|
|
|
assert_equal Mom::IntegerConstant , @inst.right.known_object.class
|
2018-03-16 14:56:27 +01:00
|
|
|
end
|
|
|
|
def test_array
|
|
|
|
check_array [SlotLoad,ReturnSequence] , @ins
|
2017-04-14 09:52:23 +02:00
|
|
|
end
|
|
|
|
end
|
2017-04-15 19:58:39 +02:00
|
|
|
class TestReturnSendMom < MiniTest::Test
|
|
|
|
include MomCompile
|
2018-03-16 14:56:27 +01:00
|
|
|
include Mom
|
2017-04-15 19:58:39 +02:00
|
|
|
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-07-01 13:12:42 +02:00
|
|
|
Risc.boot!
|
2018-04-19 09:00:55 +02:00
|
|
|
@ins = compile_first_method( "return 5.div4")
|
2017-04-15 19:58:39 +02:00
|
|
|
end
|
|
|
|
|
2018-03-16 15:09:35 +01:00
|
|
|
def test_return_is_last
|
2018-08-02 16:37:27 +02:00
|
|
|
assert_equal ReturnJump , @ins.last.class
|
2018-03-16 15:09:35 +01:00
|
|
|
end
|
2018-03-16 14:56:27 +01:00
|
|
|
def test_array
|
2018-08-02 16:37:27 +02:00
|
|
|
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,SlotLoad,ReturnJump] , @ins
|
2017-04-15 19:58:39 +02:00
|
|
|
end
|
|
|
|
end
|
2017-04-14 09:52:23 +02:00
|
|
|
end
|