2017-09-05 12:04:52 +03:00
|
|
|
|
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-04 00:36:49 +03:00
|
|
|
module Sol
|
2019-10-03 20:55:41 +03:00
|
|
|
class TestWhileConditionSlotMachine < MiniTest::Test
|
2019-10-04 00:36:49 +03:00
|
|
|
include SolCompile
|
2017-09-05 12:04:52 +03:00
|
|
|
|
|
|
|
def setup
|
2019-09-12 22:27:10 +03:00
|
|
|
@compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return" , "Integer.div4")
|
2019-10-03 20:55:41 +03:00
|
|
|
@ins = @compiler.slot_instructions.next
|
2017-09-05 12:04:52 +03:00
|
|
|
end
|
|
|
|
|
2019-08-13 11:14:36 +03:00
|
|
|
def test_condition_compiles_to_check
|
2019-08-16 14:09:56 +03:00
|
|
|
assert_equal TruthCheck , @ins.next(4).class
|
2017-09-05 12:04:52 +03:00
|
|
|
end
|
2019-08-13 11:14:36 +03:00
|
|
|
def test_condition_is_slot
|
2020-02-15 21:02:03 +07:00
|
|
|
assert_equal SlottedMessage , @ins.next(4).condition.class , @ins
|
2017-09-05 12:04:52 +03:00
|
|
|
end
|
2019-08-13 11:14:36 +03:00
|
|
|
def test_hoisetd
|
2019-08-16 14:09:56 +03:00
|
|
|
jump = @ins.next(8)
|
2018-04-20 09:56:06 +03:00
|
|
|
assert_kind_of Jump , jump
|
|
|
|
assert jump.label.name.start_with?("cond_label") , jump.label.name
|
|
|
|
end
|
2019-08-13 11:14:36 +03:00
|
|
|
def test_label
|
2018-04-20 09:56:06 +03:00
|
|
|
label = @ins
|
|
|
|
assert_equal Label , label.class
|
|
|
|
assert label.name.start_with?("cond_label") , label.name
|
2018-03-16 12:33:11 +05:30
|
|
|
end
|
2019-08-13 11:14:36 +03:00
|
|
|
def test_array
|
2019-08-16 14:09:56 +03:00
|
|
|
check_array [Label, MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck ,
|
|
|
|
MessageSetup, ArgumentTransfer, SimpleCall, Jump, Label ,
|
2019-08-17 23:29:42 +03:00
|
|
|
SlotLoad, ReturnJump,Label, ReturnSequence, Label ,Label ,
|
|
|
|
ReturnSequence, Label] , @ins
|
2017-09-05 12:04:52 +03:00
|
|
|
end
|
2018-03-16 12:33:11 +05:30
|
|
|
|
2017-09-05 12:04:52 +03:00
|
|
|
end
|
|
|
|
end
|