Fixing tests for implicit return

previous commit affected rather many test, as the implicit returns add extra instructions
Also added some explicit returns, so as not to test the return logic too much. return (ie return nl) is a knonwn 3 risc operation.
This commit is contained in:
Torsten Rüger 2019-08-17 23:29:42 +03:00
parent 32f908c127
commit 5a43cbff15
43 changed files with 152 additions and 107 deletions

View File

@ -73,7 +73,7 @@
def self.padded( len ) def self.padded( len )
a = 32 * (1 + ((len + 3)/32).floor ) a = 32 * (1 + ((len + 3)/32).floor )
#puts "#{a} for #{len}" #puts "#{a} for #{len}"
a return a
end end
def self.padded_words( words ) def self.padded_words( words )

View File

@ -6,8 +6,8 @@ module Risc
def setup def setup
super super
@input = "arg = 5" @input = "arg = 5;return"
@expect = [LoadConstant, SlotToReg, RegToSlot] @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, Branch]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -6,8 +6,8 @@ module Risc
def setup def setup
super super
@input = "@ivar = 5" @input = "@ivar = 5;return"
@expect = [LoadConstant, SlotToReg, RegToSlot] @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, Branch]
end end
def test_local_assign_instructions def test_local_assign_instructions

View File

@ -6,8 +6,9 @@ module Risc
def setup def setup
super super
@input = "local = arg" @input = "local = arg; return local"
@expect = [SlotToReg, SlotToReg, SlotToReg, RegToSlot] @expect = [SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #4
SlotToReg, RegToSlot, Branch] #9
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -6,8 +6,8 @@ module Risc
def setup def setup
super super
@input = "r = false" @input = "r = false;return"
@expect = [LoadConstant,SlotToReg, RegToSlot] @expect = [LoadConstant,SlotToReg, RegToSlot,LoadConstant, RegToSlot, Branch]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -6,8 +6,8 @@ module Risc
def setup def setup
super super
@input = "r = 5" @input = "r = 5;return"
@expect = [LoadConstant,SlotToReg, RegToSlot] @expect = [LoadConstant,SlotToReg, RegToSlot, LoadConstant, RegToSlot, Branch]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -6,9 +6,9 @@ module Risc
def setup def setup
super super
@input = "@ivar = 5 ; r = @ivar" @input = "@ivar = 5 ; r = @ivar;return"
@expect = [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg , @expect = [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
RegToSlot] RegToSlot, LoadConstant, RegToSlot, Branch]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -6,11 +6,12 @@ module Risc
def setup def setup
super super
@input = "r = 5.div4" @input = "r = 5.div4;return"
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, @expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot] FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, Branch]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -12,7 +12,7 @@ module Risc
RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg, #14 RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg, #14
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #19 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #19
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #24 SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #24
SlotToReg, FunctionCall, Label] SlotToReg, FunctionCall, Label] #29
end end
def test_send_instructions def test_send_instructions

View File

@ -18,7 +18,7 @@ module Risc
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, #44 SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, #44
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, #49 RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, #49
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, #54 LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, #54
SlotToReg, DynamicJump, Label] SlotToReg, DynamicJump, Label, SlotToReg, RegToSlot, Branch]
end end
def test_send_instructions def test_send_instructions

View File

@ -10,7 +10,7 @@ module Risc
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, @expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label] FunctionCall, Label, SlotToReg, RegToSlot, Branch]
end end
def test_send_instructions def test_send_instructions

View File

@ -11,7 +11,7 @@ module Risc
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall,
Label] Label, SlotToReg, RegToSlot, Branch]
end end
def test_send_instructions def test_send_instructions

View File

@ -6,11 +6,11 @@ module Risc
def setup def setup
super super
@input = "5.div4" @input = "return 5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, @expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label] FunctionCall, Label, SlotToReg, RegToSlot, Branch]
@produced = produce_body @produced = produce_body
end end
@ -51,7 +51,7 @@ module Risc
assert_reg_to_slot( sl , :r1 , :r3 , 7 ) assert_reg_to_slot( sl , :r1 , :r3 , 7 )
end end
def test_label def test_label
sl = @produced.next( 17 ) sl = @produced.next( 20 )
assert_equal Risc::Label , sl.class assert_equal Risc::Label , sl.class
assert_equal "return_label" , sl.name assert_equal "return_label" , sl.name
end end

View File

@ -6,11 +6,12 @@ module Risc
def setup def setup
super super
@input = "if(@a) ; arg = 5 ; else; arg = 6; end" @input = "if(@a) ; arg = 5 ; else; arg = 6; end;return"
@expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, @expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero,
LoadConstant, OperatorInstruction, IsZero, Label, LoadConstant, LoadConstant, OperatorInstruction, IsZero, Label, LoadConstant,
SlotToReg, RegToSlot, Branch, Label, LoadConstant, SlotToReg, RegToSlot, Branch, Label, LoadConstant,
SlotToReg, RegToSlot, Label] SlotToReg, RegToSlot, Label, LoadConstant, #34
RegToSlot, Branch]
end end
def test_if_instructions def test_if_instructions

View File

@ -6,10 +6,11 @@ module Risc
def setup def setup
super super
@input = "if(@a) ; arg = 5 ; end" @input = "if(@a) ; arg = 5 ; end;return"
@expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, @expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero,
LoadConstant, OperatorInstruction, IsZero, Label, LoadConstant, LoadConstant, OperatorInstruction, IsZero, Label, LoadConstant,
SlotToReg, RegToSlot, Label] SlotToReg, RegToSlot, Label, LoadConstant, #34
RegToSlot, Branch]
end end
def test_if_instructions def test_if_instructions

View File

@ -6,10 +6,11 @@ module Risc
def setup def setup
super super
@input = "unless(@a) ; arg = 5 ; end" @input = "unless(@a) ; arg = 5 ; end;return"
@expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, #4 @expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, #4
LoadConstant, OperatorInstruction, IsZero, Label, Branch, #9 LoadConstant, OperatorInstruction, IsZero, Label, Branch, #9
Label, LoadConstant, SlotToReg, RegToSlot, Label] #14 Label, LoadConstant, SlotToReg, RegToSlot, Label, LoadConstant, #34
RegToSlot, Branch] #14
end end
def test_if_instructions def test_if_instructions

View File

@ -7,7 +7,7 @@ module Mom
def setup def setup
end end
def in_test_vool(body = "@ivar = 5") def in_test_vool(body = "@ivar = 5;return")
code = in_Test("def meth; #{body};end") code = in_Test("def meth; #{body};end")
RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(code) RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(code)
end end
@ -30,7 +30,7 @@ module Mom
def test_compiles_all_risc def test_compiles_all_risc
compiler = in_test_vool().compilers.first.to_risc compiler = in_test_vool().compilers.first.to_risc
assert_equal Risc::LoadConstant , compiler.risc_instructions.next.class assert_equal Risc::LoadConstant , compiler.risc_instructions.next.class
assert_equal 17 , compiler.risc_instructions.length assert_equal 20 , compiler.risc_instructions.length
end end
end end
end end

View File

@ -6,11 +6,11 @@ module Risc
def setup def setup
super super
@input = "5.div4" @input = "return 5.div4"
@expect = "something" @expect = "something"
end end
def instruction(num) # 18 is the main, see length in test/mom/send/test_setup_simple.rb def instruction(num) # 21 is the main, see length in test/mom/send/test_setup_simple.rb
produce_main.next( 18 + num) produce_main.next( 21 + num)
end end
def test_postamble_classes def test_postamble_classes
postamble.each_with_index do |ins , index| postamble.each_with_index do |ins , index|

View File

@ -6,14 +6,15 @@ module Risc
def setup def setup
super super
@input = "while(5 > 0) ; @a = true; end" @input = "while(5 > 0) ; @a = true; end;return"
@expect = [Label, LoadConstant, LoadConstant, SlotToReg, SlotToReg, #4 @expect = [Label, LoadConstant, LoadConstant, SlotToReg, SlotToReg, #4
RegToSlot, RegToSlot, RegToSlot, RegToSlot, LoadConstant, #9 RegToSlot, RegToSlot, RegToSlot, RegToSlot, LoadConstant, #9
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, #14 SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, #14
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #19 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #19
FunctionCall, Label, SlotToReg, LoadConstant, OperatorInstruction, #24 FunctionCall, Label, SlotToReg, LoadConstant, OperatorInstruction, #24
IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant, #29 IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant, #29
SlotToReg, RegToSlot, Branch, Label] #34 SlotToReg, RegToSlot, Branch, Label, LoadConstant, #34
RegToSlot, Branch] #34
end end
def test_while_instructions def test_while_instructions

View File

@ -6,10 +6,11 @@ module Risc
def setup def setup
super super
@input = "while(@a) ; arg = 5 end" @input = "while(@a) ; arg = 5 end;return"
@expect = [Label, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, @expect = [Label, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, #4
IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant, IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant, #9
SlotToReg, RegToSlot, Branch, Label] SlotToReg, RegToSlot, Branch, Label, LoadConstant, #14
RegToSlot, Branch] #19
end end
def test_while_instructions def test_while_instructions

View File

@ -12,7 +12,7 @@ module Risc
vool.to_mom(nil) vool.to_mom(nil)
vool vool
end end
def create_method(body = "@ivar = 5") def create_method(body = "@ivar = 5;return")
in_test_vool("def meth; #{body};end") in_test_vool("def meth; #{body};end")
test = Parfait.object_space.get_class_by_name(:Test) test = Parfait.object_space.get_class_by_name(:Test)
test.get_method(:meth) test.get_method(:meth)
@ -20,7 +20,7 @@ module Risc
def test_method_has_source def test_method_has_source
method = create_method method = create_method
assert_equal Vool::IvarAssignment , method.source.class assert_equal Vool::ScopeStatement , method.source.class
end end
def test_method_has_no_locals def test_method_has_no_locals
@ -40,20 +40,20 @@ module Risc
end end
def test_creates_method_statement_in_class def test_creates_method_statement_in_class
clazz = in_test_vool("def meth; @ivar = 5 ;end") clazz = in_test_vool("def meth; @ivar = 5 ;return;end")
assert_equal Vool::Statements , clazz.body.class assert_equal Vool::Statements , clazz.body.class
assert_equal Vool::MethodStatement , clazz.body.first.class assert_equal Vool::MethodStatement , clazz.body.first.class
end end
def test_callable_method_instance_type def test_callable_method_instance_type
in_test_vool("def meth; @ivar = 5; @ibar = 4;end") in_test_vool("def meth; @ivar = 5; @ibar = 4;return;end")
test = Parfait.object_space.get_class_by_name(:Test) test = Parfait.object_space.get_class_by_name(:Test)
method = test.instance_type.get_method(:meth) method = test.instance_type.get_method(:meth)
assert_equal 1, method.self_type.variable_index(:ivar) assert_equal 1, method.self_type.variable_index(:ivar)
assert_equal 2, method.self_type.variable_index(:ibar) assert_equal 2, method.self_type.variable_index(:ibar)
end end
def test_callable_method_has_one_local def test_callable_method_has_one_local
in_test_vool("def meth; local = 5 ; a = 6;end") in_test_vool("def meth; local = 5 ; a = 6;return;end")
test = Parfait.object_space.get_class_by_name(:Test) test = Parfait.object_space.get_class_by_name(:Test)
method = test.get_method(:meth) method = test.get_method(:meth)
assert_equal 3 , method.frame_type.instance_length assert_equal 3 , method.frame_type.instance_length

View File

@ -36,21 +36,4 @@ module Ruby
assert_equal LocalAssignment , lst.body.class assert_equal LocalAssignment , lst.body.class
end end
end end
class TestMethodStatementTrans < MiniTest::Test
include RubyTests
def setup()
input = "def tryout(arg1, arg2) ; a = arg1 ; end "
@lst = compile( input ).to_vool
end
def test_method
assert_equal Vool::MethodStatement , @lst.class
end
def test_method_args
assert_equal [:arg1, :arg2] , @lst.args
end
def test_body_is_scope_zero_statement
assert_equal Vool::LocalAssignment , @lst.body.class
end
end
end end

View File

@ -0,0 +1,53 @@
require_relative "helper"
module Ruby
# other Return tests (standalone?) only test the statement
# But to get the implicit return, we test the method, as it inserts
# the implicit return
class TestMethodStatementRet < MiniTest::Test
include RubyTests
def test_single_const
@lst = compile( "def tryout(arg1, arg2) ; true ; end " ).to_vool
assert_equal Vool::ReturnStatement , @lst.body.class
end
def test_single_instance
@lst = compile( "def tryout(arg1, arg2) ; @a ; end " ).to_vool
assert_equal Vool::ReturnStatement , @lst.body.class
end
def test_single_call
@lst = compile( "def tryout(arg1, arg2) ; is_true() ; end " ).to_vool
assert_equal Vool::ReturnStatement , @lst.body.class
end
def test_multi_const
@lst = compile( "def tryout(arg1, arg2) ; @a = some_call(); true ; end " ).to_vool
assert_equal Vool::ReturnStatement , @lst.body.last.class
end
def test_multi_instance
@lst = compile( "def tryout(arg1, arg2) ; @a = some_call(); @a ; end " ).to_vool
assert_equal Vool::ReturnStatement , @lst.body.last.class
end
def test_multi_call
@lst = compile( "def tryout(arg1, arg2) ; is_true() ; some_call() ; end " ).to_vool
assert_equal Vool::ReturnStatement , @lst.body.last.class
end
def test_return
@lst = compile( "def tryout(arg1, arg2) ; return 1 ; end " ).to_vool
assert_equal Vool::ReturnStatement , @lst.body.class
assert_equal Vool::IntegerConstant , @lst.body.return_value.class
end
def test_local_assign
@lst = compile( "def tryout(arg1, arg2) ; a = 1 ; end " ).to_vool
assert_equal Vool::Statements , @lst.body.class
assert_equal Vool::ReturnStatement , @lst.body.last.class
assert_equal Vool::LocalVariable , @lst.body.last.return_value.class
end
def test_local_assign
@lst = compile( "def tryout(arg1, arg2) ; @a = 1 ; end " ).to_vool
assert_equal Vool::Statements , @lst.body.class
assert_equal Vool::ReturnStatement , @lst.body.last.class
assert_equal Vool::InstanceVariable , @lst.body.last.return_value.class
end
end
end

View File

@ -5,21 +5,20 @@ module RubyX
class TestObjecCompile < MiniTest::Test class TestObjecCompile < MiniTest::Test
include ParfaitHelper include ParfaitHelper
def source def source
load_parfait(:object2) load_parfait(:object)
end end
def test_load def test_load
assert source.include?("class Object") assert source.include?("class Object")
assert source.length > 2000 assert source.length > 2000
end end
def est_vool def test_vool
vool = compiler.ruby_to_vool source vool = compiler.ruby_to_vool source
assert_equal Vool::ClassStatement , vool.class assert_equal Vool::ClassStatement , vool.class
assert_equal :Object , vool.name assert_equal :Object , vool.name
end end
def est_mom def test_mom
vool = compiler.ruby_to_mom source vool = compiler.ruby_to_mom source
assert_equal Vool::ClassStatement , vool.class assert_equal Mom::MomCollection , vool.class
assert_equal :Object , vool.name
end end
end end
end end

View File

@ -26,7 +26,6 @@ module VoolCompile
include ScopeHelper include ScopeHelper
include Mom include Mom
def compile_first_method( input ) def compile_first_method( input )
input = as_test_main( input ) input = as_test_main( input )
collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input) collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input)

View File

@ -20,7 +20,7 @@ module Vool
assert_equal Mom::MessageSetup , @ins.class , @ins assert_equal Mom::MessageSetup , @ins.class , @ins
end end
def test_two_instructions_are_returned def test_two_instructions_are_returned
assert_equal 6 , @ins.length , @ins assert_equal 8 , @ins.length , @ins
end end
def test_receiver_move_class def test_receiver_move_class
assert_equal Mom::ArgumentTransfer, @ins.next(1).class assert_equal Mom::ArgumentTransfer, @ins.next(1).class
@ -38,8 +38,8 @@ module Vool
assert_equal Parfait::CallableMethod, @ins.next(2).method.class assert_equal Parfait::CallableMethod, @ins.next(2).method.class
end end
def test_array def test_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall,Label, check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
ReturnSequence , Label] , @ins ReturnJump,Label, ReturnSequence , Label] , @ins
end end
end end

View File

@ -20,7 +20,7 @@ module Vool
assert_equal MessageSetup , @ins.class , @ins assert_equal MessageSetup , @ins.class , @ins
end end
def test_two_instructions_are_returned def test_two_instructions_are_returned
assert_equal 6 , @ins.length , @ins assert_equal 8 , @ins.length , @ins
end end
def test_receiver_move_class def test_receiver_move_class
assert_equal ArgumentTransfer, @ins.next(1).class assert_equal ArgumentTransfer, @ins.next(1).class
@ -40,7 +40,8 @@ module Vool
assert_equal Parfait::CallableMethod, @ins.next(2).method.class assert_equal Parfait::CallableMethod, @ins.next(2).method.class
end end
def test_array def test_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall,Label, ReturnSequence , check_array [MessageSetup,ArgumentTransfer,SimpleCall,
SlotLoad, ReturnJump, Label, ReturnSequence ,
Label] , @ins Label] , @ins
end end
end end

View File

@ -21,7 +21,8 @@ module Vool
def test_array def test_array
check_array [NotSameCheck, SlotLoad, ResolveMethod, Label, MessageSetup , check_array [NotSameCheck, SlotLoad, ResolveMethod, Label, MessageSetup ,
ArgumentTransfer, DynamicCall, Label, ReturnSequence, Label] , @ins ArgumentTransfer, DynamicCall, SlotLoad, ReturnJump,
Label, ReturnSequence, Label] , @ins
end end
end end

View File

@ -7,14 +7,14 @@ module Vool
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
Risc.boot! Risc.boot!
@compiler = compile_first_method( "a = main(1 + 2)" ) @compiler = compile_first_method( "a = main(1 + 2);return a" )
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
def test_array def test_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, MessageSetup , check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, MessageSetup ,
ArgumentTransfer, SimpleCall, SlotLoad ,Label, ReturnSequence , ArgumentTransfer, SimpleCall, SlotLoad ,SlotLoad, ReturnJump,
Label] , @ins Label, ReturnSequence , Label] , @ins
end end
def test_one_call def test_one_call

View File

@ -5,7 +5,7 @@ module Vool
include VoolCompile include VoolCompile
def setup def setup
@compiler = compile_first_method( "a = 5; a.div4") @compiler = compile_first_method( "a = 5; a.div4;return ")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
def test_check_type def test_check_type
@ -27,7 +27,8 @@ module Vool
def test_array def test_array
check_array [SlotLoad, NotSameCheck, SlotLoad, ResolveMethod , check_array [SlotLoad, NotSameCheck, SlotLoad, ResolveMethod ,
Label, MessageSetup, ArgumentTransfer, DynamicCall, Label , Label, MessageSetup, ArgumentTransfer, DynamicCall,
SlotLoad, ReturnJump, Label ,
ReturnSequence, Label] , @ins ReturnSequence, Label] , @ins
end end

View File

@ -5,7 +5,7 @@ module Vool
include SimpleSendHarness include SimpleSendHarness
def send_method def send_method
"self.get_internal_word(0)" "self.get_internal_word(0);return"
end end
def test_receiver def test_receiver
assert_equal SlotDefinition, @ins.next.receiver.class assert_equal SlotDefinition, @ins.next.receiver.class

View File

@ -5,7 +5,7 @@ module Vool
include SimpleSendHarness include SimpleSendHarness
def send_method def send_method
"5.div4" "5.div4;return"
end end
def receiver def receiver
[Mom::IntegerConstant , 5] [Mom::IntegerConstant , 5]

View File

@ -5,7 +5,7 @@ module Vool
include SimpleSendHarness include SimpleSendHarness
def send_method def send_method
"5.div4(1,2)" "5.div4(1,2);return"
end end
def receiver def receiver
@ -20,8 +20,8 @@ module Vool
assert_equal 2, @ins.next(1).arguments[1].right.known_object.value assert_equal 2, @ins.next(1).arguments[1].right.known_object.value
end end
def test_array def test_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall, Label, ReturnSequence , check_array [MessageSetup,ArgumentTransfer,SimpleCall, SlotLoad, ReturnJump,
Label] , @ins Label, ReturnSequence , Label] , @ins
end end
end end
end end

View File

@ -5,7 +5,7 @@ module Vool
include SimpleSendHarness include SimpleSendHarness
def send_method def send_method
"'5'.get_internal_byte(1)" "'5'.get_internal_byte(1) ; return "
end end
def receiver def receiver
[Mom::StringConstant , "5"] [Mom::StringConstant , "5"]

View File

@ -6,7 +6,7 @@ module Vool
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "local = 5") @compiler = compile_first_method( "local = 5;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
@ -38,7 +38,7 @@ module Vool
include VoolCompile include VoolCompile
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "@a = 5 ; local = @a") @compiler = compile_first_method( "@a = 5 ; local = @a;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
def test_class_compiles def test_class_compiles
@ -52,7 +52,7 @@ module Vool
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "arg = 5") @compiler = compile_first_method( "arg = 5;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
@ -79,13 +79,13 @@ module Vool
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
end end
def test_assigns_const def test_assigns_const
@compiler = compile_first_method( "@a = 5") @compiler = compile_first_method( "@a = 5;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
assert_equal Mom::SlotLoad , @ins.class , @ins assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
end end
def test_assigns_move def test_assigns_move
@compiler = compile_first_method( "@a = arg") @compiler = compile_first_method( "@a = arg;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
assert_equal Mom::SlotLoad , @ins.class , @ins assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::SlotDefinition , @ins.right.class , @ins assert_equal Mom::SlotDefinition , @ins.right.class , @ins

View File

@ -67,7 +67,7 @@ module Vool
include VoolCompile include VoolCompile
def setup def setup
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end") @compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return")
@ins = @compiler.mom_instructions @ins = @compiler.mom_instructions
end end
@ -89,8 +89,8 @@ module Vool
end end
def test_array def test_array
check_array [Label, TruthCheck, Label, SlotLoad, Jump , check_array [Label, TruthCheck, Label, SlotLoad, Jump ,
Label, SlotLoad, Label, Label, ReturnSequence , Label, SlotLoad, Label, SlotLoad, ReturnJump ,
Label] , @ins Label, ReturnSequence, Label] , @ins
end end
end end
end end

View File

@ -7,7 +7,7 @@ module Vool
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "if(@a) ; @a = 5 ; end") @compiler = compile_first_method( "if(@a) ; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
@ -24,8 +24,8 @@ module Vool
assert_equal Label , @ins.last.class , @ins assert_equal Label , @ins.last.class , @ins
end end
def test_array def test_array
check_array [TruthCheck, Label, SlotLoad, Label, Label , check_array [TruthCheck, Label, SlotLoad, Label, SlotLoad, ReturnJump,
ReturnSequence, Label], @ins Label ,ReturnSequence, Label], @ins
end end
end end
end end

View File

@ -7,7 +7,7 @@ module Vool
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "unless(@a) ; @a = 5 ; end") @compiler = compile_first_method( "unless(@a) ; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
@ -25,7 +25,7 @@ module Vool
end end
def test_array def test_array
check_array [TruthCheck, Label, Jump, Label, SlotLoad , check_array [TruthCheck, Label, Jump, Label, SlotLoad ,
Label, Label, ReturnSequence, Label] , @ins Label, SlotLoad, ReturnJump,Label, ReturnSequence, Label] , @ins
end end
end end
end end

View File

@ -7,7 +7,7 @@ module Vool
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end") @compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
@ -25,7 +25,7 @@ module Vool
end end
def test_array def test_array
check_array [TruthCheck, Label, SlotLoad, Jump, Label , check_array [TruthCheck, Label, SlotLoad, Jump, Label ,
SlotLoad, Label, Label, ReturnSequence, Label], @ins SlotLoad, Label, SlotLoad, ReturnJump,Label, ReturnSequence, Label], @ins
end end
end end
end end

View File

@ -6,7 +6,7 @@ module Vool
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end") @compiler = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
@ -23,7 +23,7 @@ module Vool
def test_array def test_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck, Label , check_array [MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck, Label ,
SlotLoad, Jump, Label, SlotLoad, Label , SlotLoad, Jump, Label, SlotLoad, Label ,
Label, ReturnSequence, Label] , @ins SlotLoad, ReturnJump,Label, ReturnSequence, Label] , @ins
end end
end end

View File

@ -6,7 +6,7 @@ module Vool
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "while(@a) ; @a = 5 ; end") @compiler = compile_first_method( "while(@a) ; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
@ -21,7 +21,7 @@ module Vool
end end
def test_array def test_array
check_array [Label, TruthCheck, SlotLoad, Jump, Label , check_array [Label, TruthCheck, SlotLoad, Jump, Label ,
Label, ReturnSequence, Label], @ins SlotLoad, ReturnJump,Label, ReturnSequence, Label], @ins
end end
end end
end end

View File

@ -7,7 +7,7 @@ module Vool
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end") @compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end;return")
@ins = @compiler.mom_instructions.next @ins = @compiler.mom_instructions.next
end end
@ -30,7 +30,8 @@ module Vool
def test_array def test_array
check_array [Label, MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck , check_array [Label, MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck ,
MessageSetup, ArgumentTransfer, SimpleCall, Jump, Label , MessageSetup, ArgumentTransfer, SimpleCall, Jump, Label ,
Label, ReturnSequence, Label] , @ins SlotLoad, ReturnJump,Label, ReturnSequence, Label ,Label ,
ReturnSequence, Label] , @ins
end end
end end