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)
|
2018-06-29 23:39:23 +02:00
|
|
|
Risc::Builtin.boot_functions
|
2019-08-07 14:08:45 +02:00
|
|
|
@compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end")
|
|
|
|
@ins = @compiler.mom_instructions.next
|
2017-09-05 11:04:52 +02:00
|
|
|
end
|
|
|
|
|
2019-08-07 14:08:45 +02:00
|
|
|
def pest_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
|
2019-08-07 14:08:45 +02:00
|
|
|
def pest_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
|
2019-08-07 14:08:45 +02:00
|
|
|
def pest_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
|
2019-08-07 14:08:45 +02:00
|
|
|
def pest_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-07 14:08:45 +02:00
|
|
|
def pest_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
|