2017-09-05 11:04:52 +02:00
|
|
|
|
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Vool
|
|
|
|
class TestWhileConditionMom < MiniTest::Test
|
|
|
|
include MomCompile
|
2018-03-16 08:03:11 +01:00
|
|
|
include Mom
|
2017-09-05 11:04:52 +02:00
|
|
|
|
|
|
|
def setup
|
2018-06-29 23:39:23 +02:00
|
|
|
Parfait.boot!
|
|
|
|
Risc::Builtin.boot_functions
|
2018-04-19 09:00:55 +02:00
|
|
|
@ins = compile_first_method( "while(5.div4) ; 5.div4 ; end")
|
2017-09-05 11:04:52 +02:00
|
|
|
end
|
|
|
|
|
2018-03-16 08:03:11 +01:00
|
|
|
def test_condition_compiles_to_check
|
2018-03-20 19:01:42 +01:00
|
|
|
assert_equal TruthCheck , @ins.next(5).class
|
2017-09-05 11:04:52 +02:00
|
|
|
end
|
|
|
|
def test_condition_is_slot
|
2018-03-20 19:01:42 +01:00
|
|
|
assert_equal SlotDefinition , @ins.next(5).condition.class , @ins
|
2017-09-05 11:04:52 +02:00
|
|
|
end
|
|
|
|
def test_hoisetd
|
2018-04-20 08:56:06 +02:00
|
|
|
jump = @ins.next(9)
|
|
|
|
assert_kind_of Jump , jump
|
|
|
|
assert jump.label.name.start_with?("cond_label") , jump.label.name
|
|
|
|
end
|
|
|
|
def test_label
|
|
|
|
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
|
|
|
|
def test_array
|
2018-04-20 08:56:06 +02:00
|
|
|
check_array [Label, MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad ,
|
|
|
|
TruthCheck, MessageSetup, ArgumentTransfer, SimpleCall, Jump ,
|
|
|
|
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
|