2017-09-05 11:04:52 +02:00
|
|
|
|
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Vool
|
|
|
|
class TestWhileConditionMom < MiniTest::Test
|
2019-08-07 14:08:45 +02:00
|
|
|
include VoolCompile
|
2017-09-05 11:04:52 +02:00
|
|
|
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2019-08-17 22:29:42 +02:00
|
|
|
@compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end;return")
|
2019-08-07 14:08:45 +02:00
|
|
|
@ins = @compiler.mom_instructions.next
|
2017-09-05 11:04:52 +02:00
|
|
|
end
|
|
|
|
|
2019-08-13 10:14:36 +02:00
|
|
|
def test_condition_compiles_to_check
|
2019-08-16 13:09:56 +02:00
|
|
|
assert_equal TruthCheck , @ins.next(4).class
|
2017-09-05 11:04:52 +02:00
|
|
|
end
|
2019-08-13 10:14:36 +02:00
|
|
|
def test_condition_is_slot
|
2019-08-16 13:09:56 +02:00
|
|
|
assert_equal SlotDefinition , @ins.next(4).condition.class , @ins
|
2017-09-05 11:04:52 +02:00
|
|
|
end
|
2019-08-13 10:14:36 +02:00
|
|
|
def test_hoisetd
|
2019-08-16 13:09:56 +02:00
|
|
|
jump = @ins.next(8)
|
2018-04-20 08:56:06 +02:00
|
|
|
assert_kind_of Jump , jump
|
|
|
|
assert jump.label.name.start_with?("cond_label") , jump.label.name
|
|
|
|
end
|
2019-08-13 10:14:36 +02:00
|
|
|
def test_label
|
2018-04-20 08:56:06 +02:00
|
|
|
label = @ins
|
|
|
|
assert_equal Label , label.class
|
|
|
|
assert label.name.start_with?("cond_label") , label.name
|
2018-03-16 08:03:11 +01:00
|
|
|
end
|
2019-08-13 10:14:36 +02:00
|
|
|
def test_array
|
2019-08-16 13:09:56 +02:00
|
|
|
check_array [Label, MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck ,
|
|
|
|
MessageSetup, ArgumentTransfer, SimpleCall, Jump, Label ,
|
2019-08-17 22:29:42 +02:00
|
|
|
SlotLoad, ReturnJump,Label, ReturnSequence, Label ,Label ,
|
|
|
|
ReturnSequence, Label] , @ins
|
2017-09-05 11:04:52 +02:00
|
|
|
end
|
2018-03-16 08:03:11 +01:00
|
|
|
|
2017-09-05 11:04:52 +02:00
|
|
|
end
|
|
|
|
end
|