return works
This commit is contained in:
@ -3,51 +3,52 @@ require_relative "helper"
|
||||
module Vool
|
||||
class TestReturnMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method( "return 5").first
|
||||
@inst = compile_first_method( "return 5")
|
||||
end
|
||||
|
||||
def test_compiles_not_array
|
||||
assert Array != @stats.class , @stats
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @stats.first.class , @stats
|
||||
assert_equal SlotLoad , @inst.class , @inst
|
||||
end
|
||||
def test_slot_is_set
|
||||
assert @stats.first.left
|
||||
assert @inst.left
|
||||
end
|
||||
def test_two_instructions_are_returned
|
||||
assert_equal 2 , @stats.length
|
||||
assert_equal 2 , @inst.length
|
||||
end
|
||||
def test_second_is_return
|
||||
assert_equal Mom::ReturnSequence, @stats.last.class
|
||||
assert_equal ReturnSequence, @inst.last.class
|
||||
end
|
||||
def test_slot_starts_at_message
|
||||
assert_equal :message , @stats.first.left.known_object
|
||||
assert_equal :message , @inst.left.known_object
|
||||
end
|
||||
def test_slot_gets_return
|
||||
assert_equal :return_value , @stats.first.left.slots[0]
|
||||
assert_equal :return_value , @inst.left.slots[0]
|
||||
end
|
||||
def test_slot_assigns_something
|
||||
assert @stats.first.right
|
||||
assert @inst.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @stats.first.right.class
|
||||
assert_equal Mom::IntegerConstant , @inst.right.class
|
||||
end
|
||||
def test_array
|
||||
check_array [SlotLoad,ReturnSequence] , @ins
|
||||
end
|
||||
end
|
||||
class TestReturnSendMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method( "return 5.mod4").first
|
||||
@ins = compile_first_method( "return 5.mod4")
|
||||
end
|
||||
|
||||
def test_two_instructions_are_returned
|
||||
#need to implement send first
|
||||
# assert_equal 2 , @stats.length
|
||||
def test_array
|
||||
check_array [SlotLoad,ReturnSequence] , @ins
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -9,9 +9,8 @@ module Vool
|
||||
"if(10 < 12) ; a = true ; end"
|
||||
end
|
||||
def test_if_basic_hoist
|
||||
lst = compile_main( basic_if )
|
||||
assert_equal Statements , lst.class
|
||||
assert_equal IfStatement , lst.statements[1].class
|
||||
lst = RubyCompiler.compile( basic_if )
|
||||
assert_equal IfStatement , lst.class
|
||||
end
|
||||
def pest_if_basic_cond
|
||||
lst = RubyCompiler.compile( basic_if )
|
||||
|
Reference in New Issue
Block a user