2018-07-18 12:57:38 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-03 23:36:49 +02:00
|
|
|
module SolBlocks
|
2019-10-03 19:55:41 +02:00
|
|
|
class TestConditionIfSlotMachine < MiniTest::Test
|
2019-10-03 23:36:49 +02:00
|
|
|
include SolCompile
|
2018-07-18 12:57:38 +02:00
|
|
|
|
|
|
|
def setup
|
2019-09-12 21:27:10 +02:00
|
|
|
@ins = compile_main_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end" , "local=5", "Integer.div4")
|
2018-07-18 12:57:38 +02:00
|
|
|
end
|
|
|
|
|
2019-09-22 23:07:30 +02:00
|
|
|
def test_condition
|
2019-08-16 20:43:54 +02:00
|
|
|
assert_equal TruthCheck , @ins.next(3).class
|
2018-07-18 12:57:38 +02:00
|
|
|
end
|
2019-09-22 23:07:30 +02:00
|
|
|
def test_condition_is_slot
|
2020-02-15 15:02:03 +01:00
|
|
|
assert_equal SlottedMessage , @ins.next(3).condition.class , @ins
|
2018-07-18 12:57:38 +02:00
|
|
|
end
|
2019-09-22 23:07:30 +02:00
|
|
|
def test_simple_call
|
2018-07-18 12:57:38 +02:00
|
|
|
assert_equal SimpleCall , @ins.next(2).class
|
|
|
|
assert_equal :div4 , @ins.next(2).method.name
|
|
|
|
end
|
2019-08-13 10:14:36 +02:00
|
|
|
def test_array
|
2019-08-16 20:43:54 +02:00
|
|
|
check_array [MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck, Label ,
|
|
|
|
SlotLoad, Jump, Label, SlotLoad, Label ,
|
2019-08-13 19:35:27 +02:00
|
|
|
Label, ReturnSequence, Label] , @ins
|
2018-07-18 12:57:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|