2017-08-30 22:27:12 +03:00
|
|
|
|
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Vool
|
2017-08-30 22:54:03 +03:00
|
|
|
class TestConditionIfMom < MiniTest::Test
|
2017-08-30 22:27:12 +03:00
|
|
|
include MomCompile
|
2018-03-16 19:05:22 +05:30
|
|
|
include Mom
|
2017-08-30 22:27:12 +03:00
|
|
|
|
|
|
|
def setup
|
|
|
|
Risc.machine.boot
|
2018-04-19 10:00:55 +03:00
|
|
|
@ins = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
|
2017-08-30 22:27:12 +03:00
|
|
|
end
|
|
|
|
|
2018-03-16 19:05:22 +05:30
|
|
|
def test_condition
|
2018-03-21 18:54:42 +05:30
|
|
|
assert_equal TruthCheck , @ins.next(4).class
|
2017-08-30 22:54:03 +03:00
|
|
|
end
|
2017-09-04 21:31:49 +03:00
|
|
|
def test_condition_is_slot
|
2018-03-21 18:54:42 +05:30
|
|
|
assert_equal SlotDefinition , @ins.next(4).condition.class , @ins
|
2018-03-16 19:05:22 +05:30
|
|
|
end
|
|
|
|
def test_hoisted_dynamic_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
|
2018-03-16 19:05:22 +05:30
|
|
|
def test_array
|
2018-03-21 18:54:42 +05:30
|
|
|
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, TruthCheck, Label ,
|
|
|
|
SlotLoad, Jump, Label, SlotLoad, 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
|