simple sends and all whiles working
This commit is contained in:
@ -27,5 +27,8 @@ module Vool
|
||||
def test_call_has_method
|
||||
assert_equal Parfait::TypedMethod, @ins.next(3).method.class
|
||||
end
|
||||
def test_array
|
||||
check_array [Mom::MessageSetup,Mom::SlotLoad,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,39 +3,32 @@ require_relative "../helper"
|
||||
module Vool
|
||||
class TestSendCachedSimpleMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method_flat( "a = 5; a.mod4")
|
||||
@first, @second , @third ,@fourth= @stats[0],@stats[1],@stats[2],@stats[3]
|
||||
end
|
||||
|
||||
def test_compiles_not_array
|
||||
assert Array != @stats.class , @stats
|
||||
end
|
||||
def test_four_instructions_are_returned
|
||||
assert_equal 4 , @stats.length
|
||||
@ins = compile_first_method_flat( "a = 5; a.mod4")
|
||||
end
|
||||
def test_if_first
|
||||
assert_equal Mom::IfStatement , @first.class , @first
|
||||
assert_equal Mom::IfStatement , @ins.class , @ins
|
||||
end
|
||||
def test_if_condition_set
|
||||
assert_equal Mom::NotSameCheck , @first.condition.class , @first
|
||||
assert_equal Mom::NotSameCheck , @ins.condition.class , @ins
|
||||
end
|
||||
def test_if_true_moves_type
|
||||
assert_equal @first.if_true[0].class, Mom::SlotLoad , @first.if_true.to_rxf
|
||||
assert_equal @ins.if_true[0].class, Mom::SlotLoad , @ins.if_true.to_rxf
|
||||
end
|
||||
def test_if_true_resolves_setup
|
||||
assert_equal @first.if_true[1].class , Mom::MessageSetup, @first.if_true.to_rxf
|
||||
assert_equal @ins.if_true[1].class , Mom::MessageSetup, @ins.if_true.to_rxf
|
||||
end
|
||||
def test_if_true_resolves_transfer
|
||||
assert_equal @first.if_true[2].class , Mom::ArgumentTransfer, @first.if_true.to_rxf
|
||||
assert_equal @ins.if_true[2].class , Mom::ArgumentTransfer, @ins.if_true.to_rxf
|
||||
end
|
||||
def test_if_true_resolves_call
|
||||
assert_equal @first.if_true[3].class , Mom::SimpleCall, @first.if_true.to_rxf
|
||||
assert_equal @ins.if_true[3].class , Mom::SimpleCall, @ins.if_true.to_rxf
|
||||
end
|
||||
def test_if_true_resolves_move
|
||||
assert_equal @first.if_true[4].class , Mom::SlotLoad, @first.if_true.to_rxf
|
||||
assert_equal @ins.if_true[4].class , Mom::SlotLoad, @ins.if_true.to_rxf
|
||||
end
|
||||
|
||||
def test_setup_second
|
||||
@ -51,7 +44,7 @@ module Vool
|
||||
end
|
||||
|
||||
def test_array
|
||||
check_array [SlotLoad,NotSameCheck,Label,SlotLoad,MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,Label,MessageSetup,ArgumentTransfer,DynamicCall] , @stats
|
||||
check_array [SlotLoad,NotSameCheck,SlotLoad,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,SlotLoad,MessageSetup,SlotLoad,ArgumentTransfer,DynamicCall] , @ins
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -5,31 +5,31 @@ module Vool
|
||||
class TestSendSelfMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include SimpleSendHarness
|
||||
include Mom
|
||||
|
||||
def do_setup(str)
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method( str).first
|
||||
@first = @stats.first
|
||||
@ins = compile_first_method( str)
|
||||
end
|
||||
def setup
|
||||
do_setup("self.get_internal_word(0)")
|
||||
end
|
||||
|
||||
def test_receiver
|
||||
assert_equal Mom::SlotDefinition, @stats[1].receiver.right.class
|
||||
assert_equal SlotDefinition, @ins.next.right.class
|
||||
end
|
||||
|
||||
def test_arg_one
|
||||
assert_equal Mom::SlotLoad, @stats[1].arguments[0].class
|
||||
assert_equal SlotLoad, @ins.next(2).arguments[0].class
|
||||
end
|
||||
def test_call_two
|
||||
assert_equal Mom::SimpleCall, @stats[2].class
|
||||
assert_equal SimpleCall, @ins.next(3).class
|
||||
end
|
||||
def test_call_has_method
|
||||
assert_equal Parfait::TypedMethod, @stats[2].method.class
|
||||
assert_equal Parfait::TypedMethod, @ins.next(3).method.class
|
||||
end
|
||||
def test_call_has_right_method
|
||||
assert_equal :get_internal_word, @stats[2].method.name
|
||||
assert_equal :get_internal_word, @ins.next(3).method.name
|
||||
end
|
||||
end
|
||||
class TestSendSelfImplicitMom < TestSendSelfMom
|
||||
|
@ -8,19 +8,22 @@ module Vool
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method( "'5'.get_internal_byte(1)")
|
||||
@ins = compile_first_method( "'5'.get_internal_byte(1)")
|
||||
end
|
||||
def receiver
|
||||
[Mom::StringConstant , "5"]
|
||||
end
|
||||
|
||||
def test_args_one_move
|
||||
assert_equal :next_message, @stats[1].arguments[0].left.slots[0]
|
||||
assert_equal :arguments, @stats[1].arguments[0].left.slots[1]
|
||||
assert_equal :next_message, @ins.next.next.arguments[0].left.slots[0]
|
||||
assert_equal :arguments, @ins.next.next.arguments[0].left.slots[1]
|
||||
end
|
||||
def test_args_one_str
|
||||
assert_equal Mom::IntegerConstant, @stats[1].arguments[0].right.class
|
||||
assert_equal 1, @stats[1].arguments[0].right.value
|
||||
assert_equal Mom::IntegerConstant, @ins.next.next.arguments[0].right.class
|
||||
assert_equal 1, @ins.next.next.arguments[0].right.value
|
||||
end
|
||||
def test_array
|
||||
check_array [Mom::MessageSetup,Mom::SlotLoad,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user