2018-04-01 13:01:17 +02:00
|
|
|
require_relative "../helper"
|
2015-11-08 13:30:28 +01:00
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
module Risc
|
2017-01-03 21:42:40 +01:00
|
|
|
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
|
|
|
|
2018-03-11 12:32:42 +01:00
|
|
|
def pest_mult
|
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, RegToSlot, 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
|
|
|
check_return 0
|
|
|
|
end
|
2018-03-11 12:32:42 +01:00
|
|
|
def pest_overflow
|
2017-01-03 21:42:40 +01:00
|
|
|
ticks( 12 )
|
|
|
|
assert @interpreter.flags[:overflow]
|
|
|
|
end
|
2015-11-08 14:15:55 +01:00
|
|
|
|
2018-03-11 12:32:42 +01:00
|
|
|
def pest_zero
|
2017-01-03 21:42:40 +01:00
|
|
|
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
|