rubyx/test/risc/interpreter/test_plus.rb

40 lines
933 B
Ruby
Raw Normal View History

require_relative "helper"
module Risc
2017-01-03 21:42:40 +01:00
class PlusTest < MiniTest::Test
include Ticker
2017-01-03 21:42:40 +01:00
def setup
@string_input = <<HERE
class Space
int main()
return #{2**62 - 1} + 1
end
end
HERE
2017-01-03 21:42:40 +01:00
@input = s(:statements, s(:return, s(:operator_value, :+, s(:int, 4611686018427387903), s(:int, 1))))
super
end
def pest_add
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, RegToSlot, LoadConstant, SlotToReg,
2018-03-21 11:18:04 +01:00
RegToSlot, Label, FunctionReturn, Transfer, Syscall,
NilClass]
2017-01-03 21:42:40 +01:00
check_return 0
end
def pest_overflow
2017-01-03 21:42:40 +01:00
ticks( 12 )
assert @interpreter.flags[:overflow]
end
def pest_zero
2017-01-03 21:42:40 +01:00
ticks( 12 )
assert @interpreter.flags[:zero]
end
end
end