2017-08-30 22:27:12 +03:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-04 00:36:49 +03:00
|
|
|
module Sol
|
2019-10-03 20:55:41 +03:00
|
|
|
class TestConditionIfSlotMachine < MiniTest::Test
|
2019-10-04 00:36:49 +03:00
|
|
|
include SolCompile
|
2017-08-30 22:27:12 +03:00
|
|
|
|
|
|
|
def setup
|
2019-09-12 22:27:10 +03:00
|
|
|
@compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return" , "Integer.div4")
|
2019-10-03 20:55:41 +03:00
|
|
|
@ins = @compiler.slot_instructions.next
|
2017-08-30 22:27:12 +03:00
|
|
|
end
|
|
|
|
|
2019-08-13 11:14:36 +03:00
|
|
|
def test_condition
|
2019-08-16 18:42:57 +03:00
|
|
|
assert_equal TruthCheck , @ins.next(3).class
|
2017-08-30 22:54:03 +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(3).condition.class , @ins
|
2018-03-16 19:05:22 +05:30
|
|
|
end
|
2019-08-16 18:42:57 +03:00
|
|
|
def test_hoisted_call
|
2018-03-21 18:54:42 +05:30
|
|
|
assert_equal SimpleCall , @ins.next(2).class
|
2018-04-19 10:00:55 +03:00
|
|
|
assert_equal :div4 , @ins.next(2).method.name
|
2017-09-04 21:00:29 +03:00
|
|
|
end
|
2019-08-13 11:14:36 +03:00
|
|
|
def test_array
|
2019-08-16 18:42:57 +03:00
|
|
|
check_array [MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck, Label ,
|
|
|
|
SlotLoad, Jump, Label, SlotLoad, Label ,
|
2019-08-17 23:29:42 +03:00
|
|
|
SlotLoad, ReturnJump,Label, ReturnSequence, Label] , @ins
|
2017-08-30 22:27:12 +03:00
|
|
|
end
|
2018-03-16 19:05:22 +05:30
|
|
|
|
2017-08-30 22:27:12 +03:00
|
|
|
end
|
|
|
|
end
|