rubyx/test/vool/test_if_statement.rb
Torsten Rüger e6c30d98fb Fix if statements hoisting, now that send is working
Same same, just have to remembe to actually execute the condition if it is a send
Having send a possible expression, removes one tmp variable and associated move, for a little extra work.
Next return and assign (rest)
2019-08-16 18:42:57 +03:00

31 lines
879 B
Ruby

require_relative "helper"
module Vool
class TestConditionIfMom < MiniTest::Test
include VoolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
@ins = @compiler.mom_instructions.next
end
def test_condition
assert_equal TruthCheck , @ins.next(3).class
end
def test_condition_is_slot
assert_equal SlotDefinition , @ins.next(3).condition.class , @ins
end
def test_hoisted_call
assert_equal SimpleCall , @ins.next(2).class
assert_equal :div4 , @ins.next(2).method.name
end
def test_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck, Label ,
SlotLoad, Jump, Label, SlotLoad, Label ,
Label, ReturnSequence, Label] , @ins
end
end
end