first while test working
fixed logic error in test framework
This commit is contained in:
@ -22,11 +22,13 @@ module MomCompile
|
||||
include CompilerHelper
|
||||
|
||||
def compile_first_method input
|
||||
lst = Vool::VoolCompiler.ruby_to_vool as_test_main( input )
|
||||
assert_equal Parfait::Class , lst.clazz.class , lst
|
||||
@method = lst.clazz.get_method(:main)
|
||||
# works a lot like Vool.ruby_to_vool
|
||||
statements = Vool::RubyCompiler.compile as_test_main( input )
|
||||
statements = statements.normalize
|
||||
res = statements.create_objects
|
||||
assert_equal Parfait::Class , statements.clazz.class , statements
|
||||
@method = statements.clazz.get_method(:main)
|
||||
assert_equal Parfait::VoolMethod , @method.class
|
||||
res = lst.create_objects
|
||||
#puts "#{res.class}"
|
||||
res
|
||||
end
|
||||
|
@ -4,24 +4,25 @@ require_relative "helper"
|
||||
module Vool
|
||||
class TestWhileConditionMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@stats = compile_first_method( "while(@a == 5) ; 5.mod4 ; end")
|
||||
@first = @stats.first
|
||||
@ins = compile_first_method( "while(5.mod4) ; 5.mod4 ; end")
|
||||
end
|
||||
|
||||
def test_if_compiles_as_array
|
||||
assert_equal Mom::WhileStatement , @first.class , @stats
|
||||
end
|
||||
def test_condition_compiles_to_slot
|
||||
assert_equal Mom::TruthCheck , @first.condition.class
|
||||
def test_condition_compiles_to_check
|
||||
assert_equal TruthCheck , @ins.next(6).class
|
||||
end
|
||||
def test_condition_is_slot
|
||||
assert_equal Mom::SlotDefinition , @first.condition.condition.class , @stats
|
||||
assert_equal SlotDefinition , @ins.next(6).condition.class , @ins
|
||||
end
|
||||
def test_hoisetd
|
||||
assert_equal Mom::SlotLoad , @first.hoisted.class
|
||||
assert_equal MessageSetup , @ins.class
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,SlotLoad,Label,TruthCheck,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,Jump,Label] , @ins
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user