2015-11-08 13:30:28 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
2017-01-03 21:42:40 +01:00
|
|
|
module Register
|
|
|
|
class MultTest < MiniTest::Test
|
|
|
|
include Ticker
|
|
|
|
include AST::Sexp
|
2015-11-08 13:30:28 +01:00
|
|
|
|
2017-01-03 21:42:40 +01:00
|
|
|
def setup
|
|
|
|
@string_input = <<HERE
|
|
|
|
class Space
|
|
|
|
int main()
|
|
|
|
return #{2**31} * #{2**31}
|
|
|
|
end
|
2015-11-08 13:30:28 +01:00
|
|
|
end
|
|
|
|
HERE
|
2017-01-03 21:42:40 +01:00
|
|
|
@input = s(:statements, s(:return, s(:operator_value, :*, s(:int, 2147483648), s(:int, 2147483648))))
|
|
|
|
super
|
|
|
|
end
|
2015-11-08 13:30:28 +01:00
|
|
|
|
2017-01-03 21:42:40 +01:00
|
|
|
def test_mult
|
|
|
|
#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, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
RegToSlot, Label, FunctionReturn, RegisterTransfer, Syscall,
|
|
|
|
NilClass]
|
2017-01-03 21:42:40 +01:00
|
|
|
check_return 0
|
|
|
|
end
|
|
|
|
def test_overflow
|
|
|
|
ticks( 12 )
|
|
|
|
assert @interpreter.flags[:overflow]
|
|
|
|
end
|
2015-11-08 14:15:55 +01:00
|
|
|
|
2017-01-03 21:42:40 +01:00
|
|
|
def test_zero
|
|
|
|
ticks( 12 )
|
|
|
|
assert @interpreter.flags[:zero]
|
|
|
|
end
|
2015-11-08 13:30:28 +01:00
|
|
|
|
2017-01-03 21:42:40 +01:00
|
|
|
end
|
2015-11-08 13:30:28 +01:00
|
|
|
end
|