2017-09-12 16:49:42 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Vool
|
|
|
|
class TestSendCachedSimpleMom < MiniTest::Test
|
|
|
|
include MomCompile
|
|
|
|
|
|
|
|
def setup
|
|
|
|
Risc.machine.boot
|
|
|
|
@stats = compile_first_method( "arg.mod4").first
|
2017-12-05 20:46:37 +01:00
|
|
|
@first, @second , @third ,@fourth= @stats[0],@stats[1],@stats[2],@stats[3]
|
2017-09-12 16:49:42 +02:00
|
|
|
end
|
|
|
|
|
2017-09-14 15:07:02 +02:00
|
|
|
def test_compiles_not_array
|
2017-09-12 16:49:42 +02:00
|
|
|
assert Array != @stats.class , @stats
|
|
|
|
end
|
2017-12-05 20:46:37 +01:00
|
|
|
def test_four_instructions_are_returned
|
|
|
|
assert_equal 4 , @stats.length
|
|
|
|
end
|
2017-09-14 17:42:01 +02:00
|
|
|
def test_if_first
|
|
|
|
assert_equal Mom::IfStatement , @first.class , @first
|
|
|
|
end
|
|
|
|
def test_if_condition_set
|
|
|
|
assert_equal Mom::NotSameCheck , @first.condition.class , @first
|
|
|
|
end
|
|
|
|
def test_if_true_set
|
|
|
|
assert @first.if_true , @first
|
2017-09-12 16:49:42 +02:00
|
|
|
end
|
2017-10-05 15:41:45 +02:00
|
|
|
def test_if_true_not_empty
|
2017-12-05 20:46:37 +01:00
|
|
|
assert @first.if_true.first , @first.to_rxf
|
2017-10-05 15:41:45 +02:00
|
|
|
end
|
2017-12-05 20:46:37 +01:00
|
|
|
def test_if_true_not_empty
|
|
|
|
assert @first.if_true.first , @first.to_rxf
|
2017-09-12 16:49:42 +02:00
|
|
|
end
|
2017-12-05 20:46:37 +01:00
|
|
|
def test_setup_second
|
|
|
|
assert_equal Mom::MessageSetup , @second.class , @second.to_rxf
|
2017-09-12 16:49:42 +02:00
|
|
|
end
|
2017-12-05 20:46:37 +01:00
|
|
|
|
|
|
|
def test_transfer_third
|
|
|
|
assert_equal Mom::ArgumentTransfer , @third.class , @third.to_rxf
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_call_third
|
|
|
|
assert_equal Mom::DynamicCall , @fourth.class , @fourth.to_rxf
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_call_third
|
|
|
|
assert @fourth.method_var_name.start_with?("cached_") , @fourth.to_rxf
|
|
|
|
end
|
|
|
|
|
2017-09-12 16:49:42 +02:00
|
|
|
def est_receiver_move_class
|
|
|
|
assert_equal Mom::SlotConstant, @first.class
|
|
|
|
end
|
|
|
|
def est_receiver_move
|
|
|
|
assert_equal :receiver, @first.left[2]
|
|
|
|
end
|
|
|
|
def est_receiver
|
|
|
|
assert_equal IntegerStatement, @first.right.class
|
|
|
|
assert_equal 5, @stats.first.right.value
|
|
|
|
end
|
|
|
|
def est_call_is
|
|
|
|
assert_equal Mom::SimpleCall, @stats[1].class
|
|
|
|
end
|
|
|
|
def est_call_has_method
|
|
|
|
assert_equal Parfait::TypedMethod, @stats[1].method.class
|
|
|
|
end
|
|
|
|
def est_call_has_right_method
|
|
|
|
assert_equal :mod4, @stats[1].method.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|