2016-12-27 19:32:38 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
module Risc
|
2017-01-03 21:42:40 +01:00
|
|
|
class IfSimpleTest < MiniTest::Test
|
|
|
|
include Ticker
|
2017-04-10 15:12:15 +02:00
|
|
|
include CleanCompile
|
2016-12-27 19:32:38 +01:00
|
|
|
|
2017-01-03 21:42:40 +01:00
|
|
|
def setup
|
|
|
|
@string_input = <<HERE
|
|
|
|
class Space
|
|
|
|
int main()
|
|
|
|
if_zero( 10 - 12)
|
|
|
|
"then".putstring()
|
|
|
|
else
|
|
|
|
"else".putstring()
|
|
|
|
end
|
2016-12-27 19:32:38 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
2017-01-03 21:42:40 +01:00
|
|
|
@input = s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:int, 10), s(:int, 12))),
|
2017-01-16 08:34:47 +01:00
|
|
|
s(:true_statements, s(:call, :putstring, s(:arguments), s(:receiver, s(:string, "then")))),
|
|
|
|
s(:false_statements, s(:call, :putstring, s(:arguments), s(:receiver, s(:string, "else"))))))
|
2016-12-27 19:32:38 +01:00
|
|
|
|
2017-01-03 21:42:40 +01:00
|
|
|
super
|
|
|
|
end
|
2016-12-27 19:32:38 +01:00
|
|
|
|
2018-03-11 12:32:42 +01:00
|
|
|
def pest_if
|
2017-01-03 21:42:40 +01:00
|
|
|
#show_ticks # get output of what is
|
2017-01-04 20:36:46 +01:00
|
|
|
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
|
|
|
|
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,
|
|
|
|
LoadConstant, OperatorInstruction, IsZero, SlotToReg, LoadConstant,
|
|
|
|
RegToSlot, LoadConstant, RegToSlot, LoadConstant, SlotToReg,
|
2018-03-21 11:18:04 +01:00
|
|
|
RegToSlot, LoadConstant, RegToSlot, Transfer, FunctionCall,
|
2017-01-04 20:36:46 +01:00
|
|
|
Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
|
2018-03-21 11:18:04 +01:00
|
|
|
SlotToReg, Transfer, Syscall, Transfer, Transfer,
|
|
|
|
RegToSlot, Label, FunctionReturn, Transfer, SlotToReg,
|
2017-01-04 20:36:46 +01:00
|
|
|
SlotToReg, Branch, Label, LoadConstant, SlotToReg,
|
2018-03-21 11:18:04 +01:00
|
|
|
RegToSlot, Label, FunctionReturn, Transfer, Syscall,
|
2017-01-04 20:36:46 +01:00
|
|
|
NilClass]
|
2017-01-03 21:42:40 +01:00
|
|
|
end
|
2016-12-27 19:32:38 +01:00
|
|
|
end
|
|
|
|
end
|