remove duplicate tests
This commit is contained in:
parent
ad4690d719
commit
4a79d20a40
@ -1 +1,80 @@
|
||||
require_relative "../helper"
|
||||
require_relative '../helper'
|
||||
|
||||
module Risc
|
||||
module SpaceHack
|
||||
# test hack to in place change object type
|
||||
def add_space_field(name,type)
|
||||
class_type = Parfait.object_space.get_class_by_name(:Space).instance_type
|
||||
class_type.send(:private_add_instance_variable, name , type)
|
||||
end
|
||||
end
|
||||
module ExpressionHelper
|
||||
include SpaceHack
|
||||
|
||||
def check
|
||||
Risc.machine.boot unless Risc.machine.booted
|
||||
compiler = Vm::MethodCompiler.new Parfait.object_space.get_main
|
||||
code = Vm.ast_to_code @input
|
||||
assert code.to_s , @input
|
||||
produced = compiler.process( code )
|
||||
assert @output , "No output given"
|
||||
assert_equal produced.class , @output , "Wrong class"
|
||||
produced
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module Statements
|
||||
include AST::Sexp
|
||||
include CleanCompile
|
||||
include SpaceHack
|
||||
|
||||
def setup
|
||||
Risc.machine.boot # force boot to reset main
|
||||
end
|
||||
|
||||
def preamble
|
||||
[Label, LoadConstant, SlotToReg, RegToSlot ]
|
||||
end
|
||||
def postamble
|
||||
[ Label, FunctionReturn]
|
||||
end
|
||||
def check_nil
|
||||
assert @expect , "No output given"
|
||||
Vool::VoolCompiler.ruby_to_vool "class Space; def main(arg);#{@input};end;end"
|
||||
produced = Parfait.object_space.get_main.instructions
|
||||
compare_instructions produced , @expect
|
||||
end
|
||||
def check_return
|
||||
was = check_nil
|
||||
raise was if was
|
||||
Parfait.object_space.get_main.instructions
|
||||
end
|
||||
|
||||
def compare_instructions( instruction , expect )
|
||||
index = 0
|
||||
all = instruction.to_arr
|
||||
full_expect = preamble + expect + postamble
|
||||
#full_expect = expect
|
||||
begin
|
||||
should = full_expect[index]
|
||||
return "No instruction at #{index}\n#{should(all)}" unless should
|
||||
return "Expected at #{index+1}\n#{should(all)}" unless instruction.class == should
|
||||
puts instruction.to_s
|
||||
index += 1
|
||||
instruction = instruction.next
|
||||
end while( instruction )
|
||||
nil
|
||||
end
|
||||
def should( all )
|
||||
preamble.each {all.shift}
|
||||
postamble.each {all.pop}
|
||||
str = all.to_s.gsub("Risc::","")
|
||||
ret = ""
|
||||
str.split(",").each_slice(6).each do |line|
|
||||
ret += " " + line.join(",") + " ,\n"
|
||||
end
|
||||
ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,55 +1,106 @@
|
||||
require_relative "helper"
|
||||
require_relative 'helper'
|
||||
|
||||
module Mom
|
||||
class TestConstToIvarAssignemnt < MiniTest::Test
|
||||
include MomCompile
|
||||
module Risc
|
||||
class TestAssignStatement < MiniTest::Test
|
||||
include Statements
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method_flat( "@a = 5")
|
||||
def pest_assign_local_assign
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = "r = 5"
|
||||
@expect = [LoadConstant, RegToSlot]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def test_if_compiles
|
||||
assert_equal SlotConstant , @stats.class , @stats
|
||||
end
|
||||
def test_length
|
||||
assert_equal 1 , @stats.length
|
||||
end
|
||||
def test_assigns_class
|
||||
assert_equal Mom::IntegerConstant , @stats.right.class , @stats.inspect
|
||||
end
|
||||
def test_assigns_value
|
||||
assert_equal 5 , @stats.right.value , @stats.inspect
|
||||
def pest_assign_op
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = "r = 10.mod4"
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def pest_assign_ivar_notpresent
|
||||
@input = "@r = 5"
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
class TestConstToLocalAssignemnt < MiniTest::Test
|
||||
include MomCompile
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method_flat( "a = 5")
|
||||
|
||||
def pest_assign_ivar
|
||||
add_space_field(:r , :Integer)
|
||||
|
||||
@input =s(:statements, s(:i_assignment, s(:ivar, :r), s(:int, 5)))
|
||||
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, Label, FunctionReturn]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
def test_if_compiles
|
||||
assert_equal SlotConstant , @stats.class , @stats
|
||||
|
||||
def pest_assign_call
|
||||
Parfait.object_space.get_main.add_local(:r , :Object)
|
||||
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:call, :main, s(:arguments))))
|
||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RiscTransfer ,
|
||||
FunctionCall, Label, RiscTransfer, SlotToReg, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
def test_length
|
||||
assert_equal 1 , @stats.length
|
||||
|
||||
def pest_named_list_get
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:int, 5)), s(:return, s(:local, :r)))
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
was = check_return
|
||||
get = was.next(5)
|
||||
assert_equal SlotToReg , get.class
|
||||
assert_equal 1 + 1, get.index , "Get to named_list index must be offset, not #{get.index}"
|
||||
end
|
||||
|
||||
def pest_assign_local_int
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:int, 5)) )
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, Label, FunctionReturn]
|
||||
was = check_return
|
||||
set = was.next(3)
|
||||
assert_equal RegToSlot , set.class
|
||||
assert_equal 1 + 1, set.index , "Set to named_list index must be offset, not #{set.index}"
|
||||
end
|
||||
class TestIvarToLocalAssignemnt < MiniTest::Test
|
||||
include MomCompile
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method_flat( "a = @a")
|
||||
|
||||
def pest_misassign_local
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:string, "5")) )
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_raises {check }
|
||||
end
|
||||
def test_if_compiles
|
||||
assert_equal SlotMove , @stats.class , @stats
|
||||
|
||||
def pest_assign_arg
|
||||
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
||||
@input = s(:statements, s(:a_assignment, s(:arg, :blar), s(:int, 5)))
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, Label, FunctionReturn]
|
||||
was = check_return
|
||||
set = was.next(3)
|
||||
assert_equal RegToSlot , set.class
|
||||
assert_equal 1 + 1, set.index , "Set to args index must be offset, not #{set.index}"
|
||||
end
|
||||
def test_length
|
||||
assert_equal 1 , @stats.length
|
||||
|
||||
def pest_misassign_arg
|
||||
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
||||
@input = s(:statements, s(:a_assignment, s(:arg, :blar), s(:string, "5")))
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_raises {check }
|
||||
end
|
||||
def test_assigns_class
|
||||
assert_equal Mom::SlotDefinition , @stats.right.class , @stats.inspect
|
||||
|
||||
def pest_arg_get
|
||||
# have to define bar externally, just because redefining main. Otherwise that would be automatic
|
||||
Parfait.object_space.get_main.add_argument(:balr , :Integer)
|
||||
@input = s(:statements, s(:return, s(:arg, :balr)))
|
||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, Label, FunctionReturn]
|
||||
was = check_return
|
||||
get = was.next(2)
|
||||
assert_equal SlotToReg , get.class
|
||||
assert_equal 1 + 1, get.index , "Get to args index must be offset, not #{get.index}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,29 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestDynamicCall < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method_flat( "a = 5; a.mod4")
|
||||
@first = @stats.next
|
||||
end
|
||||
|
||||
def test_if_compiles
|
||||
assert_equal @stats.last.class , DynamicCall , @stats
|
||||
end
|
||||
def test_check
|
||||
assert_equal NotSameCheck , @first.class
|
||||
end
|
||||
def test_condition_is_slot
|
||||
assert_equal SlotDefinition , @first.left.class , @first
|
||||
end
|
||||
def test_length
|
||||
assert_equal 12 , @stats.length
|
||||
end
|
||||
def test_array
|
||||
check_array [SlotConstant,NotSameCheck,Label,SlotMove,MessageSetup,ArgumentTransfer,SimpleCall,SlotMove,Label,MessageSetup,ArgumentTransfer,DynamicCall] , @stats
|
||||
end
|
||||
end
|
||||
end
|
@ -1,29 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestSimpleIfMom < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method_flat( "if(@a == 5) ; 5.mod4 ; end")
|
||||
@first = @stats.next
|
||||
end
|
||||
|
||||
def test_if_compiles
|
||||
assert IfStatement != @stats.class , @stats
|
||||
end
|
||||
def test_check
|
||||
assert_equal TruthCheck , @first.class
|
||||
end
|
||||
def test_condition_is_slot
|
||||
assert_equal SlotDefinition , @first.condition.class , @first
|
||||
end
|
||||
def test_length
|
||||
assert_equal 7 , @stats.length
|
||||
end
|
||||
def test_array
|
||||
check_array [SlotMove,TruthCheck,Label,MessageSetup,ArgumentTransfer,SimpleCall,Label], @stats
|
||||
end
|
||||
end
|
||||
end
|
@ -1,30 +0,0 @@
|
||||
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestConditionIfMom < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method_flat( "if(@a == 5) ; 5.mod4 ; else; 4.mod4 ; end")
|
||||
@first = @stats.next
|
||||
end
|
||||
|
||||
def test_if_compiles
|
||||
assert IfStatement != @stats.class , @stats
|
||||
end
|
||||
def test_check
|
||||
assert_equal TruthCheck , @first.class
|
||||
end
|
||||
def test_condition_is_slot
|
||||
assert_equal SlotDefinition , @first.condition.class , @first
|
||||
end
|
||||
def test_length
|
||||
assert_equal 11 , @stats.length
|
||||
end
|
||||
def test_array
|
||||
check_array [SlotMove,TruthCheck,Label,MessageSetup,ArgumentTransfer,SimpleCall,Label,MessageSetup,ArgumentTransfer,SimpleCall,Label] , @stats
|
||||
end
|
||||
end
|
||||
end
|
@ -1,10 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestInstruction < MiniTest::Test
|
||||
|
||||
def test_class_exists
|
||||
assert Instruction.new
|
||||
end
|
||||
end
|
||||
end
|
@ -1,23 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestSimpleCall < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method_flat( "5.mod4")
|
||||
@first = @stats.next
|
||||
end
|
||||
|
||||
def test_if_compiles
|
||||
assert_equal @stats.last.class , SimpleCall , @stats
|
||||
end
|
||||
def test_method_name
|
||||
assert_equal @stats.last.method.name , :mod4 , @stats.last.to_rxf
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall] , @stats
|
||||
end
|
||||
end
|
||||
end
|
@ -1,30 +0,0 @@
|
||||
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestWhileConditionMom < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method_flat( "while(@a == 5) ; 5.mod4 ; end")
|
||||
@first = @stats.next.next
|
||||
end
|
||||
|
||||
def test_if_compiles
|
||||
assert IfStatement != @stats.class , @stats
|
||||
end
|
||||
def test_check
|
||||
assert_equal TruthCheck , @first.class
|
||||
end
|
||||
def test_condition_is_slot
|
||||
assert_equal SlotDefinition , @first.condition.class , @first
|
||||
end
|
||||
def test_length
|
||||
assert_equal 4 , @stats.length
|
||||
end
|
||||
def test_array
|
||||
check_array [Label,SlotMove,TruthCheck,Label] , @stats
|
||||
end
|
||||
end
|
||||
end
|
@ -1,80 +0,0 @@
|
||||
require_relative '../helper'
|
||||
|
||||
module Risc
|
||||
module SpaceHack
|
||||
# test hack to in place change object type
|
||||
def add_space_field(name,type)
|
||||
class_type = Parfait.object_space.get_class_by_name(:Space).instance_type
|
||||
class_type.send(:private_add_instance_variable, name , type)
|
||||
end
|
||||
end
|
||||
module ExpressionHelper
|
||||
include SpaceHack
|
||||
|
||||
def check
|
||||
Risc.machine.boot unless Risc.machine.booted
|
||||
compiler = Vm::MethodCompiler.new Parfait.object_space.get_main
|
||||
code = Vm.ast_to_code @input
|
||||
assert code.to_s , @input
|
||||
produced = compiler.process( code )
|
||||
assert @output , "No output given"
|
||||
assert_equal produced.class , @output , "Wrong class"
|
||||
produced
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module Statements
|
||||
include AST::Sexp
|
||||
include CleanCompile
|
||||
include SpaceHack
|
||||
|
||||
def setup
|
||||
Risc.machine.boot # force boot to reset main
|
||||
end
|
||||
|
||||
def preamble
|
||||
[Label, LoadConstant, SlotToReg, RegToSlot ]
|
||||
end
|
||||
def postamble
|
||||
[ Label, FunctionReturn]
|
||||
end
|
||||
def check_nil
|
||||
assert @expect , "No output given"
|
||||
Vool::VoolCompiler.ruby_to_vool "class Space; def main(arg);#{@input};end;end"
|
||||
produced = Parfait.object_space.get_main.instructions
|
||||
compare_instructions produced , @expect
|
||||
end
|
||||
def check_return
|
||||
was = check_nil
|
||||
raise was if was
|
||||
Parfait.object_space.get_main.instructions
|
||||
end
|
||||
|
||||
def compare_instructions( instruction , expect )
|
||||
index = 0
|
||||
all = instruction.to_arr
|
||||
full_expect = preamble + expect + postamble
|
||||
#full_expect = expect
|
||||
begin
|
||||
should = full_expect[index]
|
||||
return "No instruction at #{index}\n#{should(all)}" unless should
|
||||
return "Expected at #{index+1}\n#{should(all)}" unless instruction.class == should
|
||||
puts instruction.to_s
|
||||
index += 1
|
||||
instruction = instruction.next
|
||||
end while( instruction )
|
||||
nil
|
||||
end
|
||||
def should( all )
|
||||
preamble.each {all.shift}
|
||||
postamble.each {all.pop}
|
||||
str = all.to_s.gsub("Risc::","")
|
||||
ret = ""
|
||||
str.split(",").each_slice(6).each do |line|
|
||||
ret += " " + line.join(",") + " ,\n"
|
||||
end
|
||||
ret
|
||||
end
|
||||
end
|
||||
end
|
@ -1,107 +0,0 @@
|
||||
|
||||
require_relative 'helper'
|
||||
|
||||
module Risc
|
||||
class TestAssignStatement < MiniTest::Test
|
||||
include Statements
|
||||
|
||||
def pest_assign_local_assign
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = "r = 5"
|
||||
@expect = [LoadConstant, RegToSlot]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def pest_assign_op
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = "r = 10.mod4"
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def pest_assign_ivar_notpresent
|
||||
@input = "@r = 5"
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def pest_assign_ivar
|
||||
add_space_field(:r , :Integer)
|
||||
|
||||
@input =s(:statements, s(:i_assignment, s(:ivar, :r), s(:int, 5)))
|
||||
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, Label, FunctionReturn]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def pest_assign_call
|
||||
Parfait.object_space.get_main.add_local(:r , :Object)
|
||||
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:call, :main, s(:arguments))))
|
||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RiscTransfer ,
|
||||
FunctionCall, Label, RiscTransfer, SlotToReg, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def pest_named_list_get
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:int, 5)), s(:return, s(:local, :r)))
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
was = check_return
|
||||
get = was.next(5)
|
||||
assert_equal SlotToReg , get.class
|
||||
assert_equal 1 + 1, get.index , "Get to named_list index must be offset, not #{get.index}"
|
||||
end
|
||||
|
||||
def pest_assign_local_int
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:int, 5)) )
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, Label, FunctionReturn]
|
||||
was = check_return
|
||||
set = was.next(3)
|
||||
assert_equal RegToSlot , set.class
|
||||
assert_equal 1 + 1, set.index , "Set to named_list index must be offset, not #{set.index}"
|
||||
end
|
||||
|
||||
def pest_misassign_local
|
||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:string, "5")) )
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_raises {check }
|
||||
end
|
||||
|
||||
def pest_assign_arg
|
||||
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
||||
@input = s(:statements, s(:a_assignment, s(:arg, :blar), s(:int, 5)))
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, Label, FunctionReturn]
|
||||
was = check_return
|
||||
set = was.next(3)
|
||||
assert_equal RegToSlot , set.class
|
||||
assert_equal 1 + 1, set.index , "Set to args index must be offset, not #{set.index}"
|
||||
end
|
||||
|
||||
def pest_misassign_arg
|
||||
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
||||
@input = s(:statements, s(:a_assignment, s(:arg, :blar), s(:string, "5")))
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||
assert_raises {check }
|
||||
end
|
||||
|
||||
def pest_arg_get
|
||||
# have to define bar externally, just because redefining main. Otherwise that would be automatic
|
||||
Parfait.object_space.get_main.add_argument(:balr , :Integer)
|
||||
@input = s(:statements, s(:return, s(:arg, :balr)))
|
||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, Label, FunctionReturn]
|
||||
was = check_return
|
||||
get = was.next(2)
|
||||
assert_equal SlotToReg , get.class
|
||||
assert_equal 1 + 1, get.index , "Get to args index must be offset, not #{get.index}"
|
||||
end
|
||||
end
|
||||
end
|
@ -6,7 +6,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method( "arg.mod4").first
|
||||
@stats = compile_first_method_flat( "a = 5; a.mod4")
|
||||
@first, @second , @third ,@fourth= @stats[0],@stats[1],@stats[2],@stats[3]
|
||||
end
|
||||
|
||||
@ -50,5 +50,9 @@ module Vool
|
||||
assert_equal Mom::DynamicCall , @fourth.class , @fourth.to_rxf
|
||||
end
|
||||
|
||||
def test_array
|
||||
check_array [SlotConstant,NotSameCheck,Label,SlotMove,MessageSetup,ArgumentTransfer,SimpleCall,SlotMove,Label,MessageSetup,ArgumentTransfer,DynamicCall] , @stats
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -22,5 +22,8 @@ module Vool
|
||||
assert_equal Mom::IntegerConstant, @stats[1].arguments[1].right.class
|
||||
assert_equal 2, @stats[1].arguments[1].right.value
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall] , @stats
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -26,5 +26,8 @@ module Vool
|
||||
def test_nothing_hoisted
|
||||
assert_nil @first.hoisted , @stats
|
||||
end
|
||||
def test_array
|
||||
check_array [SlotMove,TruthCheck,Label,MessageSetup,ArgumentTransfer,SimpleCall,Label], @stats
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -26,5 +26,8 @@ module Vool
|
||||
def test_nothing_hoisted
|
||||
assert_nil @first.hoisted , @stats
|
||||
end
|
||||
def test_array
|
||||
check_array [Label,SlotMove,TruthCheck,Label] , @stats
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user