2018-04-27 20:56:41 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Vool
|
|
|
|
class TestSendArgsSendMom < MiniTest::Test
|
2019-08-12 10:57:32 +02:00
|
|
|
include VoolCompile
|
2018-04-27 20:56:41 +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!
|
2019-08-17 22:29:42 +02:00
|
|
|
@compiler = compile_first_method( "a = main(1 + 2);return a" )
|
2019-08-07 14:08:45 +02:00
|
|
|
@ins = @compiler.mom_instructions.next
|
2018-04-27 20:56:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_array
|
|
|
|
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, MessageSetup ,
|
2019-08-17 22:29:42 +02:00
|
|
|
ArgumentTransfer, SimpleCall, SlotLoad ,SlotLoad, ReturnJump,
|
|
|
|
Label, ReturnSequence , Label] , @ins
|
2018-04-27 20:56:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_one_call
|
|
|
|
assert_equal SimpleCall, @ins.next(2).class
|
|
|
|
assert_equal :+, @ins.next(2).method.name
|
|
|
|
end
|
|
|
|
def test_two_call
|
|
|
|
assert_equal SimpleCall, @ins.next(6).class
|
|
|
|
assert_equal :main, @ins.next(6).method.name
|
|
|
|
end
|
|
|
|
def test_args_one_l
|
|
|
|
left = @ins.next(1).arguments[0].left
|
|
|
|
assert_equal Symbol, left.known_object.class
|
|
|
|
assert_equal :message, left.known_object
|
2019-08-22 20:24:02 +02:00
|
|
|
assert_equal [:next_message, :arg1], left.slots
|
2018-04-27 20:56:41 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|