rubyx/test/risc/interpreter/wip/test_simple_if.rb

43 lines
1.4 KiB
Ruby
Raw Normal View History

2018-04-01 13:01:17 +02:00
require_relative "../helper"
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
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
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))),
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"))))))
2017-01-03 21:42:40 +01:00
super
end
def pest_if
2017-01-03 21:42:40 +01:00
#show_ticks # get output of what is
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,
Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
2018-03-21 11:18:04 +01:00
SlotToReg, Transfer, Syscall, Transfer, Transfer,
RegToSlot, Label, FunctionReturn, Transfer, SlotToReg,
SlotToReg, Branch, Label, LoadConstant, SlotToReg,
2018-03-21 11:18:04 +01:00
RegToSlot, Label, FunctionReturn, Transfer, Syscall,
NilClass]
2017-01-03 21:42:40 +01:00
end
end
end